Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to not lose points on death?

Asked by 8 years ago
local x = game.Workspace.tpReceive.Position.X
local y = game.Workspace.tpReceive.Position.Y
local z = game.Workspace.tpReceive.Position.Z

function onTouched(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        local gui = player.PlayerGui.PointsGui.PointsFrame.Points
        local number = tonumber(gui.Text)
        if number == nil then number = 0 
        end
        number = number+1
        gui.Text = number
        wait()
        for i, object in pairs(game.Workspace:GetChildren()) do
            if object:FindFirstChild("Humanoid") then
             local torso = object:FindFirstChild("Torso") 
            torso.CFrame = CFrame.new(x, y, z)
            end
        end
        if not game.Workspace:FindFirstChild("Message") then
            local message = Instance.new("Message")
            message.Text = hit.Parent.Name.." wins!"
            message.Parent = game.Workspace
            wait(3)
            message:Destroy()
        end
    end
end

script.Parent.Touched:connect(onTouched)

Thats the script I have right now, but whenever I reset or fall off the cliff, my character loses all of their points, how do I fix this? Thanks a million guys! :)

1 answer

Log in to vote
0
Answered by
8391ice 91
8 years ago

You have stored the points in the player's GUI; unfortunately, values in the PlayerGUI will reset if a player dies or resets. It would be better for you to store the points in a leaderboard, because the points will then remain the same even after a player's death.

If you'd like to know how to create a leaderboard, it's really rather simple; here's a link to a Wiki article for it.

http://wiki.roblox.com/index.php?title=Leaderboard

Hope this helps!

Ad

Answer this question