I'm trying to activate a lava block's script when the TimePosition is at 75 and 80 seconds, but nothing's happened at those times. Could I get a little help? Thank you in advance!
function scoop() script.Parent.BrickColor = BrickColor.new("Really Red") script.Parent.scooper:Play() if script.Parent.scooper.TimePosition == 75 then game.Workspace.Lava.Script.Disabled = false end if script.Parent.scooper.TimePosition == 80.00 then script.Parent.scooper:Stop() game.Workspace.Lava.Script.Disabled = true end wait(5) script.Parent.BrickColor = BrickColor.new("Lime Green") end script.Parent.ClickDetector.MouseClick:connect(scoop)
(Also, the button I'm clicking on doesn't change to the Really Red color once clicked if anyone wants to help me with that but that's not really important now!)
The issue here is that Doubles (what TimePosition is) are not very precise.
Checking if TimePosition is exactly equal to a number is useless, but you also aren't waiting at all for it, so the if
statements are being checked immediately!
function scoop() script.Parent.BrickColor = BrickColor.new("Really Red") script.Parent.scooper:Play() wait(75) while script.Parent.scooper.TimePosition < 75 do wait() end game.Workspace.Lava.Script.Disabled = false wait(5) while script.Parent.scooper.TimePosition < 80 do wait() end script.Parent.scooper:Stop() game.Workspace.Lava.Script.Disabled = true wait(5) script.Parent.BrickColor = BrickColor.new("Lime Green") end script.Parent.ClickDetector.MouseClick:connect(scoop)