My goal is to make an obby level and respawn system, the problem is when i enter the game(in studio) my level gets set to different numbers based on my Total spawnLocations as checkpoints(20). Although if my level at the start is 0 as it should be it works perfectly fine. I added enabling and disabling to the spawnlocations to see if that would fix it but it didnt, all help is appreciated:
local DCS = workspace.DifficultyChartSpawns
for _, spawner in pairs(DCS:GetChildren()) do
--//Player touching spawner\\--
spawner.Touched:Connect(function(object)
if object.Parent:FindFirstChild("Humanoid") then
local humanoid = object.Parent:FindFirstChild("Humanoid")
local player = game:GetService("Players"):GetPlayerFromCharacter(humanoid.Parent)
if tonumber(spawner.Name) >= player.leaderstats.Level.Value then
spawner.Enabled = true
player.leaderstats.Level.Value = tonumber(spawner.Name)
--Turning it green
script.Completed:Play()
spawner.Color = Color3.fromRGB(0, 255, 0)
player.RespawnLocation = spawner
else
spawner.Enabled = false
end
end
end)
end