I made a teleportation transfer system and weirdly enough it transfers me to my current stage and then it transfers me to the other stages perfectly as shown in the video:
I don’t know why it perfectly transfer me afterwards but not at first here are a few scripts which could be causing this issue. I’m pretty sure this is what’s causing it Level.Text = CurrentValue.Value
the text value is the GUI that changes when the current value changes. Let me know if you need to know what something is or more information because I’ll gladly provide it to you with what I know!
The GUI handler:
local UI = script.Parent
local player = game.Players.LocalPlayer
local checkpoints = workspace:WaitForChild("Checkpoints")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Teleport = ReplicatedStorage:WaitForChild("Teleport")
local remoteEvent = ReplicatedStorage:WaitForChild("remoteEvent")
local Counter = UI:WaitForChild("Counter")
local Level = Counter:WaitForChild("Level")
local Previous = UI:WaitForChild("Previous")
local Next = UI:WaitForChild("Next")
local Previous1 = UI:WaitForChild("Previous1")
local Next1 = UI:WaitForChild("Next1")
local CurrentValue = UI:WaitForChild("Current")
local function previousLevel()
script.Parent.Handler.Click:Play()
if CurrentValue.Value ~= 1 then
Level.Text = CurrentValue.Value
print("sent back 1 level")
-- teleport
Teleport:FireServer(checkpoints:FindFirstChild(tostring(CurrentValue.Value)))
end
end
local function previousLevel2()
script.Parent.Handler.Click:Play()
if CurrentValue.Value >= 11 then
Level.Text = CurrentValue.Value
print("sent back 10 levels")
-- teleport
Teleport:FireServer(checkpoints:FindFirstChild(tostring(CurrentValue.Value)))
end
end
local function nextLevel()
script.Parent.Handler.Click:Play()
if (CurrentValue.Value + 1) <= player.leaderstats.Stage.Value then
Level.Text = CurrentValue.Value
print("sent forward 1 level")
-- teleport
Teleport:FireServer(checkpoints:FindFirstChild(tostring(CurrentValue.Value)))
end
end
local function nextLevel2()
script.Parent.Handler.Click:Play()
if (CurrentValue.Value + 10) <= player.leaderstats.Stage.Value then
Level.Text = CurrentValue.Value
print("sent forward 10 levels")
-- teleport
Teleport:FireServer(checkpoints:FindFirstChild(tostring(CurrentValue.Value)))
end
end
Previous.MouseButton1Click:Connect(function()
previousLevel()
remoteEvent:FireServer("updateCurrent", player.PlayerGui.Level.Current.Value - 1)
remoteEvent:FireServer("updateSpawnPoint", player.hidden.SpawnPoint.Value - 1)
end)
Previous1.MouseButton1Click:Connect(function()
previousLevel2()
remoteEvent:FireServer("updateCurrent", player.PlayerGui.Level.Current.Value - 10)
remoteEvent:FireServer("updateSpawnPoint", player.hidden.SpawnPoint.Value - 10)
end)
Next.MouseButton1Click:Connect(function()
nextLevel()
remoteEvent:FireServer("updateCurrent", player.PlayerGui.Level.Current.Value + 1)
remoteEvent:FireServer("updateSpawnPoint", player.hidden.SpawnPoint.Value + 1)
end)
Next1.MouseButton1Click:Connect(function()
nextLevel2()
remoteEvent:FireServer("updateCurrent", player.PlayerGui.Level.Current.Value + 10)
remoteEvent:FireServer("updateSpawnPoint", player.hidden.SpawnPoint.Value + 10)
end)
CurrentValue.Value = player:WaitForChild("leaderstats").Stage.Value
Level.Text = CurrentValue.Value
player.leaderstats.Stage:GetPropertyChangedSignal("Value"):Connect(function()
CurrentValue.Value = player.leaderstats.Stage.Value
Level.Text = CurrentValue.Value
end)
Remote Event script:
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("remoteEvent")
remoteEvent.OnServerEvent:Connect(function(plr, job, msg)
if job == "updateCurrent" then
print("updated current")
plr.PlayerGui.Level.Current.Value = msg
end
if job == "updateSpawnPoint" then
print("updated spawnpoint")
plr.hidden.SpawnPoint.Value = msg
end
end)