Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How in the world, this keeps erroring? [PLEASE HELP!]

Well I made this door that activates with spacebar once the players torso is touching the part defined, but the thing is the script will run find the door will open and close, but 2 things the user can "spam" the spacebar and break it and once the script runs once and i try to run it again it jitters and won't slide the right way, here is the link?

www.roblox.com/SH-item?id=163931688

local open = script.Parent.Parent.DoorPart.Open
local close = script.Parent.Parent.DoorPart.Closed

if script.Running.Value == true then
return end
script.Running.Value=true
while true do wait(0.1)
if open.Value == false then
	print"Open"
	for i = 1, 4.9, 0.1 do
		script.Parent.CFrame=script.Parent.CFrame*CFrame.new(0.2,0,0)
		wait()
		wait(WaitTime)
	open.Value=true
	close.Value=false
	end
	wait(3)
else if open.Value == true then
	while true do wait(0.1)
		if open.Value == true then
			print"Close"
			for i = 1, 4.9, 0.1 do
				script.Parent.CFrame=script.Parent.CFrame*CFrame.new(-0.2,0,0)
				wait()
				wait(WaitTime)
				open.Value=false
				close.Value=true
				script.Disabled=true
				script.Running.Value=false
				wait()
			end
		end
	end
end
end
end
----DoorScript
local PLR = game.Players.LocalPlayer
PLR.Character["Torso"].Touched:connect(function(hit)
	if hit.Name == "DoorOpen" then
 game.Players.LocalPlayer:GetMouse().KeyDown:connect(function(key)
  if key == " " then
   if hit.Parent.DoorPart.Script.Running.Value ~= false and hit.Parent.DoorPart.Open.Value ~= false then
	print"OpenWithLocalScript"
hit.Parent.DoorPart.Script.Disabled=false
wait(5)
hit.Parent.DoorPart.Script.Disabled=true
else
	if hit.Parent.DoorPart.Script.Running.Value ~= true then
	return end
end
end
end)
	end
end)

Door control script

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.