It's hard scripting when tired. I need sleep.
local elevator = script.Parent.Parent.Move.BodyPosition local Ready = script.Parent.Parent.Panel.Ready.Value local Floor = script.Parent.Parent.Panel.Floor.Value function Activate() if Floor >= 1 and Floor < 3 and Ready == true then Ready = false Floor = Floor + 1 elevator.position = elevator.position + Vector3.new(0,32,0) wait(2) Ready = true end end script.Parent.ClickDetector.MouseClick:connect(Activate)
`
"Floor" is a number value.
Every part of the script works but the adding part.
Edit: Odd, two things:
Ready value is also not changing,
the elevator is still not going beyond floor 3, despite the Floor value remaining the same.
This is an incredibly common mistake.
Lines 2 and 3 accomplish almost nothing. The .Value
property will evaluate to false
/ 0
(their default), so you just set the value false
to Ready
and Floor
.
Later, changing those variables just changes those variables -- it isn't somehow linked to the values.
Solution: Use a variable to store the object, and explicitly modify its properties:
local Floor = script.Parent.Parent.Panel.Floor ... if Floor.Value >= 1 and Floor.Value < 3 and Ready.Value then ...