I have a movement GUI that teleports a player around during a game. However, by the second round, it stops working. Why is it doing that?
Server Script (Part of it):
local function assignRoutes()
local num = 1
local routes = {
{startingLocations.Bloxian1Start, bloxianTeleports.Bloxian1["Bloxian1[2]"],
bloxianTeleports.Bloxian1["Bloxian1[3]"], bloxianTeleports.Bloxian1["Bloxian1[4]"],
hallwayTeleports.Hallway1, doorTeleports.Door1},
{startingLocations.Bloxian2Start, bloxianTeleports.Bloxian2["Bloxian2[2]"],
hallwayTeleports.Hallway1, doorTeleports.Door1},
{startingLocations.Bloxian3Start, bloxianTeleports.Bloxian3["Bloxian3[2]"],
hallwayTeleports.Hallway2, doorTeleports.Door2},
{startingLocations.Bloxian4Start, bloxianTeleports.Bloxian4["Bloxian4[2]"],
bloxianTeleports.Bloxian4["Bloxian4[3]"], bloxianTeleports.Bloxian4["Bloxian4[4]"],
hallwayTeleports.Hallway2, doorTeleports.Door2}
}
for _, plr in pairs(players) do
if plr:WaitForChild("Info").Role.Value == "Bloxian" then
assign:FireClient(plr, routes[num])
num = num + 1
end
end
print("Routes Given")
end
Local Script (In StarterCharacterScripts):
player = game.Players.LocalPlayer
character = player.Character or player.CharacterAdded:Wait()
humanoid = character:WaitForChild("Humanoid")
assignRoutes = game.ReplicatedStorage.Remotes.AssignRoutes
canPass1 = game.ReplicatedStorage.Remotes.CanPass1
canPass2 = game.ReplicatedStorage.Remotes.CanPass2
getWeapon = game.ReplicatedStorage.Remotes.GetWeapon
door1 = workspace.EmptyHouse.Door1.Closed
door2 = workspace.EmptyHouse.Door2.Closed
gui = player:WaitForChild("PlayerGui"):WaitForChild("BloxianPanel").EmptyHouseNavigation
assignRoutes.OnClientEvent:Connect(function(route)
print("Route Received")
local index = 1
local timer = 0
humanoid.WalkSpeed = 0
humanoid.JumpPower = 0
character:MoveTo(route[index].Position)
gui.MoveOn.Visible = false
wait(8)
gui.MoveOn.Visible = true
gui.MoveOn.MouseButton1Click:Connect(function()
timer = 0
if index == #route then
if route[index] == workspace.EmptyHouse.BloxianTeleports.DoorTeleports.Door1 then
if not canPass1:InvokeServer() then
character:MoveTo(workspace.EmptyHouse.BloxianTeleports.JumpscareZone.Position)
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
getWeapon:FireServer()
gui.MoveOn.Visible = false
return
else
index = 0
end
end
if route[index] == workspace.EmptyHouse.BloxianTeleports.DoorTeleports.Door2 then
if not canPass2:InvokeServer() then
character:MoveTo(workspace.EmptyHouse.BloxianTeleports.JumpscareZone.Position)
humanoid.WalkSpeed = 16
humanoid.JumpPower = 50
getWeapon:FireServer()
gui.MoveOn.Visible = false
return
else
index = 0
end
end
end
index = index + 1
character:MoveTo(route[index].Position)
gui.MoveOn.Visible = false
wait(8)
gui.MoveOn.Visible = true
while true do
if gui.MoveOn.Visible == true then
wait(1)
timer = timer + 1
if timer == 8 then
index = 1
character:MoveTo(route[index].Position)
break
end
else
break
end
end
end)
end)
