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 😭
man , thx so much . Finally i made functioning door without free models . I set the Model's primary part to Hinge and it works now :D
Appreciate the help bro, saved me like 2 hrs of building man, liked and subbed
Amazing seeing people helping others. I wish you the best!
Literally life saver! Thank you so much!
congrats on 100 subscribers
edit: great video as always
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?
Don't forget to set the hinge to the primary part!
bro I CANT FIND PRIMARY PART HELP
That helped a lot! I subscribed, thank you.
Amazing as always
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
Yas I love creating functions :O)
it's working, but when i open and close it i can't open or close again, why??
Thank you so much!
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???
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.
Amazing tysm
Btw 3rd :)
My problem is the hing isnt in the primaty part and i dont know how to fix it
my door opens but it wont close, i've tried changing the script a bit but none would work
Always gotta pay attention to it or else it fail 🍷🗿
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
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
and make a player get i speed every sec.
it doesn't show a press e button
same bro what the fuck
i cant find primarypart
You have to add model to the door folder! I was confused too
i can make a npc move
it doesnt work but i still love ur vids
clickbait