Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to not lose points on death?

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

✓ Accepted answer

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!

This discussion is preserved as it was. New answers, comments, and votes are closed.