Hi, so I’m having trouble making the Current Value changing to the SpawnPoint Value. I made a visual representation of what should happen at the bottom… Thanks for your time!
local checkpoints = workspace:WaitForChild("Checkpoints")
for i,v in pairs(checkpoints:GetChildren()) do
if v:IsA("BasePart") then
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if tonumber(v.Name) == player.leaderstats.Stage.Value + 1 then --Checks if the new checkpoint is only increasing by 1.
player.leaderstats.Stage.Value = tonumber(v.Name)
elseif tonumber(v.Name) <= player.leaderstats.Stage.Value then
print("TEST")
player.PlayerGui.Level.Current.Value = player.hidden.SpawnPoint.Value == tonumber(v.Name) -- this line!!!
end
end
end)
end
end
-- 214 current = 214 spawnpoint
-- 203 current = 203 spawnpoint
I shouldn’t be able to do this, however I should be able to use the stage transfer feature to do this and it saves me there instead of me walking on it.
local checkpoints = workspace:WaitForChild("Checkpoints")
for i,v in pairs(checkpoints:GetChildren()) do
if v:IsA("BasePart") then
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if tonumber(v.Name) == player.leaderstats.Stage.Value + 1 then --Checks if the new checkpoint is only increasing by 1.
player.leaderstats.Stage.Value = tonumber(v.Name)
elseif tonumber(v.Name) <= player.leaderstats.Stage.Value then
print("TEST")
player.hidden.SpawnPoint.Value = player.PlayerGui.Level.Current.Value
player.hidden.SpawnPoint.Value = tonumber(v.Name)
end
end
end)
end
end
-- 214 current = 214 spawnpoint
-- 203 current = 203 spawnpoint
What I’m trying to fix is me stepping on previous stages and it saving me there, but instead I should be able to transfer through stages (top gui) and whatever the current stage value is it should save me at that number value by equaling it to the SpawnPoint (a temp value for going to previous stages)
Yep, the Stage value is the farthest stage they’ve gotten too; the SpawnPoint acts as a placeholder for other levels so you can respawn at other previous stages too.
Which stage number are you talking about? Like the GUI one or?
This boolvalue is wired to the changing of the GUI, this isn’t linked to the stage number but they’re obviously related because this displays what stage they’re at. All this does is change the number for the GUI.
Yeah, that number is supposed to show what stage the player is on, so shouldn’t it change even if the player is progressing?
My point being ur not changing the text when the player is moving to the next stage
if tonumber(v.Name) == player.leaderstats.Stage.Value + 1 then --Checks if the new checkpoint is only increasing by 1.
player.leaderstats.Stage.Value = tonumber(v.Name) -- ur not changing the text of the UI
elseif tonumber(v.Name) <= player.leaderstats.Stage.Value then
print("TEST")
player.hidden.SpawnPoint.Value = player.PlayerGui.Level.Current.Value -- whats the point of this?
player.hidden.SpawnPoint.Value = tonumber(v.Name)
end
Well it does, the GUI is fine, it’s just me staying at previous stages because currently I can walk on ones which I don’t want to be able to happen. Instead I want it so that I can only transfer through stages to change my SpawnPoint value, the placeholder for previous stages so I can go to them without respawning at my up-to-date stage. Useful for helping other players or replaying the game, etc.
The GUI is actually broken when I reset, I’ll fix that later.
Basically it works 50%, but the other 50% is what I need to fix which is me stepping on previous stages and it spawning me there. This should only be able to happen If I transfer through stages.
This issue is still happening, the Current Value won’t change to the SpawnPoint value. I deleted it to see if it changed anything and it didn’t. I’ve discoverd a possible lead on what may be causing this issue which is (hit.Parent) after local player = game.Players:GetPlayerFromCharacter(hit.Parent)
Here’s the update to date script:
local checkpoints = workspace:WaitForChild("Checkpoints")
for i,v in pairs(checkpoints:GetChildren()) do
if v:IsA("BasePart") then
v.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if tonumber(v.Name) == player.leaderstats.Stage.Value + 1 then --Checks if the new checkpoint is only increasing by 1.
player.leaderstats.Stage.Value = tonumber(v.Name)
elseif tonumber(v.Name) <= player.leaderstats.Stage.Value then
print("TEST")
player.hidden.SpawnPoint.Value = player.PlayerGui.Level.Current.Value
player.hidden.SpawnPoint.Value = tonumber(v.Name)
end
end
end)
end
end
-- 214 current = 214 spawnpoint
-- 203 current = 203 spawnpoint
Visual representation for what I want at the bottom of the script.