this may fix it
01 | local boat = script.Parent |
02 | local CanTeleport = false |
03 | local teleportscript = game.Workspace.Teleports.TeleportPad 1. Teleport |
05 | local function BoatMove() |
09 | boat:TranslateBy(Vector 3. new( 1 , 0 , 0 )) |
13 | boat:TranslateBy(Vector 3. new(- 1 , 0 , 0 )) |
19 | local function CanTeleportToggle() |
28 | local function CanTeleportCheck() |
30 | if CanTeleport = = false then |
31 | teleportscript.Disabled = true |
32 | elseif CanTeleport = = true then |
33 | teleportscript.Disabled = false |
40 | spawn(CanTeleportToggle) |
41 | 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