local tweenService = game:GetService("TweenService") local doors = script.Parent:GetChildren() local function Tween(object, goal, easingStyle, tweenTime) local tween = tweenService:Create(object, TweenInfo.new(tweenTime, easingStyle), goal)
return tween end for i, model in pairs(doors) do if model:IsA("Model") then for i, part in pairs(model:GetChildren()) do if part ~= model.PrimaryPart and part:IsA("BasePart") then local weld = Instance.new("WeldConstraint") weld.Parent = model.PrimaryPart weld.Part0 = model.PrimaryPart weld.Part1 = part
part.Anchored = false end end end end for i, model in pairs(doors) do if model:IsA("Model") then local open = false local debouce = false
local prompt1 = Instance.new("ProximityPrompt") prompt1.Parent = model.Handle1 prompt1.ActionText = "Open"
local prompt2 = Instance.new("ProximityPrompt") prompt2.Parent = model.Handle2 prompt2.ActionText = "Open"
prompt1.Triggered:Connect(function(player) if debouce == false then debouce = true
if open then open = false prompt1.ActionText = "Open" prompt2.ActionText = "Open"
local tween = Tween(model.PrimaryPart, {CFrame = model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(100), 0)}, Enum.EasingStyle.Sine, 1) tween:Play() else open = true prompt1.ActionText = "Close" prompt2.ActionText = "Close" local tween = Tween(model.PrimaryPart, {CFrame = model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(-100), 0)}, Enum.EasingStyle.Sine, 1) tween:Play() end task.wait(1) debouce = false end end)
prompt2.Triggered:Connect(function(player) if debouce == false then debouce = true if open then open = false prompt1.ActionText = "Open" prompt2.ActionText = "Open" local tween = Tween(model.PrimaryPart, {CFrame = model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(100), 0)}, Enum.EasingStyle.Sine, 1) tween:Play() else open = true prompt1.ActionText = "Close" prompt2.ActionText = "Close" local tween = Tween(model.PrimaryPart, {CFrame = model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(-100), 0)}, Enum.EasingStyle.Sine, 1) tween:Play() end task.wait(1) debouce = false end end) end end
I dontk ow much about code, but i know the logic, you can make that when the AI aproaches, it opens the door automatically, you cane make the game detect if the AI is there and close
tysm, I've been trying to get a working door from different videos for 3 HOURSSSS but it wasn't working, and now it works. I appriciate u dawg 😭
congrats on 100 subscribers
edit: great video as always
Appreciate the help bro, saved me like 2 hrs of building man, liked and subbed
Don't forget to set the hinge to the primary part!
bro I CANT FIND PRIMARY PART HELP
Amazing seeing people helping others. I wish you the best!
Amazing tysm
Btw 3rd :)
Literally life saver! Thank you so much!
Amazing as always
That helped a lot! I subscribed, thank you.
That Helped Me For The Game, Thx, And Also, I Change The Script A little For The Sound Of The Door, And For An ObjectText In The ProximityPrompt
Wait how can I add a sound?
local tweenService = game:GetService("TweenService")
local doors = script.Parent:GetChildren()
local function Tween(object, goal, easingStyle, tweenTime)
local tween = tweenService:Create(object, TweenInfo.new(tweenTime, easingStyle), goal)
return tween
end
for i, model in pairs(doors) do
if model:IsA("Model") then
for i, part in pairs(model:GetChildren()) do
if part ~= model.PrimaryPart and part:IsA("BasePart") then
local weld = Instance.new("WeldConstraint")
weld.Parent = model.PrimaryPart
weld.Part0 = model.PrimaryPart
weld.Part1 = part
part.Anchored = false
end
end
end
end
for i, model in pairs(doors) do
if model:IsA("Model") then
local open = false
local debouce = false
local prompt1 = Instance.new("ProximityPrompt")
prompt1.Parent = model.Handle1
prompt1.ActionText = "Open"
local prompt2 = Instance.new("ProximityPrompt")
prompt2.Parent = model.Handle2
prompt2.ActionText = "Open"
prompt1.Triggered:Connect(function(player)
if debouce == false then
debouce = true
if open then
open = false
prompt1.ActionText = "Open"
prompt2.ActionText = "Open"
local tween = Tween(model.PrimaryPart, {CFrame = model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(100), 0)}, Enum.EasingStyle.Sine, 1)
tween:Play()
else
open = true
prompt1.ActionText = "Close"
prompt2.ActionText = "Close"
local tween = Tween(model.PrimaryPart, {CFrame = model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(-100), 0)}, Enum.EasingStyle.Sine, 1)
tween:Play()
end
task.wait(1)
debouce = false
end
end)
prompt2.Triggered:Connect(function(player)
if debouce == false then
debouce = true
if open then
open = false
prompt1.ActionText = "Open"
prompt2.ActionText = "Open"
local tween = Tween(model.PrimaryPart, {CFrame = model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(100), 0)}, Enum.EasingStyle.Sine, 1)
tween:Play()
else
open = true
prompt1.ActionText = "Close"
prompt2.ActionText = "Close"
local tween = Tween(model.PrimaryPart, {CFrame = model.PrimaryPart.CFrame * CFrame.Angles(0, math.rad(-100), 0)}, Enum.EasingStyle.Sine, 1)
tween:Play()
end
task.wait(1)
debouce = false
end
end)
end
end
Thx man
it isnt hsowing the E button for me and the parts also keep falling
did you weld, make it a model, anchor the correct parts and add a proximity prompt???
Yas I love creating functions :O)
Thank you so much!
How do you make the door open in the opposite direction?
6 months late response but the solution I found out was to just rotate the door vertically.
my door opens but it wont close, i've tried changing the script a bit but none would work
it's working, but when i open and close it i can't open or close again, why??
Hello. very cool. Question: Is it possible for AI to open and close the same door?
I dontk ow much about code, but i know the logic, you can make that when the AI aproaches, it opens the door automatically, you cane make the game detect if the AI is there and close
Always gotta pay attention to it or else it fail 🍷🗿
can you make a script for the custom proximity prompt
My door keeps falling down into pieces and yes I anchored it but idk why it keeps falling down
same i m very confused
i cant find primarypart
You have to add model to the door folder! I was confused too
and make a player get i speed every sec.
i can make a npc move
it doesn't show a press e button
same bro what the fuck
it doesnt work but i still love ur vids
clickbait