#Why game crash

15 messages · Page 1 of 1 (latest)

lucid wind
#

Whenever I touch sp1 or sp2 idk what happens it just breaks the game they are supposed to be checkpoints and I supposed dont want them to save, doesn't i even tried continue but it doesn't work

languid sparrow
#

can u paste the script in here?

#

is ur game crashing?

#

ur not saving the value wehn the player leaves so "Stage" is always 0

#

and im guessing ur game is not loading because u got an infinite loop in there

#
local sp1 = game.Workspace.sp1 -- change this to your path
local sp2 = game.Workspace.sp2 -- change this to your path


game.Players.PlayerAdded:Connect(function(plr) -- this is already the player
    local leaderstats = Instance.new("Folder")
    leaderstats.Name = "leaderstats" -- leaderstats is the only right way doing a leaderboard
    leaderstats.Parent = plr.Character

    local Stage = Instance.new("IntValue")
    Stage.Name = "Stage"
    Stage.Parent = leaderstats
end)

sp1.Touched:Connect(function(player) -- this is already the player
    if player.leaderstats then
        player.leaderstats.Stage.Value = 1
    end
end)

sp2.Touched:Connect(function(player) -- this is already the player
    if player.leaderstats then
        player.leaderstats.Stage.Value = 2
    end
end)
    
-- Look on documentation how your saving values in ServerStorage :)

this should fix your problems

lucid wind
#

local sp1 = game.Workspace.GameArea.Spawn1
local sp2 = game.Workspace.GameArea.Spawn2

game.Players.PlayerAdded:Connect(function(plr)
local leader = Instance.new("Folder",plr)
leader.Name = "LeaderBoard"
local Stage = Instance.new("IntValue",leader)
Stage.Value = 1
while true do
wait()
sp1.Touched:Connect(function(hit)
local chr = game.Players:GetPlayerFromCharacter(hit.Parent)
if chr:FindFirstChild("LeaderBoard") then
Stage.Value = 1
wait(1)
end
end)
sp2.Touched:Connect(function(hit)
local chr = game.Players:GetPlayerFromCharacter(hit.Parent)
print("Checking fro LeaderBoard")
if chr:FindFirstChild("LeaderBoard") then
Stage.Value = 2
print("Stage Value changed")
wait(1)
end
end)
plr.CharacterAdded:Connect(function(char)
wait()
if Stage.Value == 1 then
char:MoveTo(sp1.Position)
print("character respawned")
wait(1)
elseif Stage.Value == 2 then
char:MoveTo(sp2.Position)
print("character respawn value changed")
wait(1)
end
end)
end
end)

#

this is actually the current script that im using and the problem i find that it prints stage value changed 5000 times

languid sparrow
#

why aint u using the script I sent you

#

this fixes everything

#

and you need to store the Value through ServerStorage

#

watch tutorials abt saving values

#

mb i fucked up the script

#
local sp1 = game.Workspace.sp1 -- change this to your path
local sp2 = game.Workspace.sp2 -- change this to your path


game.Players.PlayerAdded:Connect(function(player) -- this is already the player
    local leaderstats = Instance.new("Folder", player)
    leaderstats.Name = "leaderstats" -- leaderstats is the only right way doing a leaderboard

    local Stage = Instance.new("IntValue", leaderstats)
    Stage.Name = "Stage"
end)

sp1.Touched:Connect(function(player) -- this is already the player
    player.leaderstats.Stage.Value = 1 -- we dont really need to check anything
end)

sp2.Touched:Connect(function(player) -- this is already the player
    player.leaderstats.Stage.Value = 1 -- we dont really need to check anything 
end)

-- look on documentation how your saving values in ServerStorage :)

just use this script

full hornetBOT
#

studio** You are now Level 5! **studio