I have tried many times to make this work, and still can not get this correct, any help would be appreciated.
local boat = script.Parent local CanTeleport = false local teleportscript = game.Workspace.Teleports.TeleportPad1.Teleport while true do wait(10) for i = 1,300 do boat:TranslateBy(Vector3.new(1,0,0)) wait() end for i = 1,300 do boat:TranslateBy(Vector3.new(-1,0,0)) wait() end end while true do wait (10) CanTeleport = true wait (10) CanTeleport = false end if CanTeleport == false then teleportscript.Disabled = true if CanTeleport == true then teleportscript.Disabled = false end end
this may fix it
local boat = script.Parent local CanTeleport = false local teleportscript = game.Workspace.Teleports.TeleportPad1.Teleport local function BoatMove() while true do wait(10) for i = 1,300 do boat:TranslateBy(Vector3.new(1,0,0)) wait() end for i = 1,300 do boat:TranslateBy(Vector3.new(-1,0,0)) wait() end end end local function CanTeleportToggle() while true do CanTeleport = true wait (10) CanTeleport = false wait (10) end end local function CanTeleportCheck() while true do if CanTeleport == false then teleportscript.Disabled = true elseif CanTeleport == true then teleportscript.Disabled = false end wait() end end spawn(BoatMove) spawn(CanTeleportToggle) spawn(CanTeleportCheck)
Basically what went wrong was the code was not able to advance due to the while loops not being in a coroutine or spawn. I went with spawn()
for this, but you could also use coroutine.wrap()
, both yielding pretty much the same result. Also, your if statement
at the end of your code needed to be changed to be in a while loop. This way should work, but infinitely looping isnt always the best way to do things. If I were you, I would look into other options such as GetProperyChangedSignal()
. If anything here doesnt work, or you need help, feel free to ask