Help with scripting a proximity prompt door

hello, this is my first post and i am making a proximity prompt multiparts door, made of meshes, welded with the Weld Model plugin, but ihave issues, the script doesn´t work, i am new to scripting but i understand some things, i followed a tutorial on the door, but i haven´t been able to make it work, i would appreciate any advice on this, thanks!

local TweenService = game:GetService("TweenService")
local door = script.Parent
local doorHinge = door.PrimaryPart
local doorOpen = TweenInfo.new()
--Names the Variables 
local doorCFrame = TweenService:Create(doorHinge, doorOpen, {
	CFrame = doorHinge.CFrame * CFrame.Angles(0, math.rad(-100),0) --change previous angle (0) to whatever value for the range of swing.
	
})

local doorCframeClosed = TweenService:Create(doorHinge, doorOpen, {
	CFrame = doorHinge.CFrame * CFrame.Angles(0, math.rad(0),0) --changes the -100 to 0 value to close the door 
})

local ProximityPrompt = script.Parent.ProximityPrompt
local PromptVanish = ProximityPrompt.Enabled == false
local PromptAppear = ProximityPrompt.Enabled == true

ProximityPrompt.Triggered:Connect(function(
	doorCFrame:Play()
	ProximityPrompt.Enable = false
	script.Parent.Open:Play()--play the open sound
	task.wait(3) --door stays open for this long
	doorCframeClosed:Play()
	ProximityPrompt.Enabled = true
	task.wait(1)
	script.Parent.Close:Play()
end)
2 Likes

I haven’t read through everything but have you checked the output for any errors?

Theres an error here.

ProximityPrompt.Triggered:Connect(function()
4 Likes

oh, maybe thats why, lemme see

It also looks like your TweenInfo is empty, unless the default values are fine with you.

umm, rn im having an issue, roblox studio crashes when i run, so i might check that later

UPDATE: sorry for the lack of activity, fortunately it works now, the door opens, but now instead of waiting the set amount of seconds to then close after, i just never closes

Make sure the prompt isn’t called multiple times when its opening / closing, else it can “open” multiple times.

Yeah, maybe add a debounce to the prompt so it can’t be used after it has been opened

nvm i fixed it, i had a horrible typo in “Enabled”
btw thanks with the help, i appreciate it

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.