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

My script doors will not work at all. Here is the script for it. Is it right?

Should this be right? When the BoolValue is checked then it opens my doors.

if script.Parent.openvalue.Value == true then
	script.Parent.Door.ld.CanCollide = false
	script.Parent.Door.rd.CanCollide = false
	script.Parent.DoorStatus2.SurfaceGui.TextLabel.Text = ("Open")
	script.Parent.SO2.SurfaceGui.TextLabel.Text = ("Open")
	
	
if script.Parent.openvalue.Value == false then
	script.Parent.Door.ld.CanCollide = false
	script.Parent.Door.rd.CanCollide = false
	script.Parent.DoorStatus2.SurfaceGui.TextLabel.Text = ("Closed")
	script.Parent.SO2.SurfaceGui.TextLabel.Text = ("Closed")
end
	
end

2 answers

✓ Accepted answer

You have to make the computer check it every time! This script only allows it to check if the door is open or closed only 1 time when the game runs And if it is false, then the script ends. And you don't put ( ) at the start or end of the text! Just " Try this:

while true do
wait()
if script.Parent.openvalue.Value == true then
    script.Parent.Door.ld.CanCollide = false
    script.Parent.Door.rd.CanCollide = false
    script.Parent.DoorStatus2.SurfaceGui.TextLabel.Text = "Open"
    script.Parent.SO2.SurfaceGui.TextLabel.Text = "Open"


else
if script.Parent.openvalue.Value == false then
    script.Parent.Door.ld.CanCollide = false
    script.Parent.Door.rd.CanCollide = false
    script.Parent.DoorStatus2.SurfaceGui.TextLabel.Text = "Closed"
    script.Parent.SO2.SurfaceGui.TextLabel.Text = "Closed"
end

end
end

1 comment

1

This isn't wrong, but a more efficient method would be to use the Changed event

Hmm ok. But when I run the game the doors are open and not closed.

1 comment

0

Ok it worked! Thanks!

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