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

How to change leaderboard stats once I travel through a teleport.?

I am finishing up my game and I want it to reset the stats from the leaderboard back to default numbers once I travel through the final teleport. I can't understand why it isn't working. Here is the script I have so far.

local plr = game.Players:GetPlayerByUserId()
script.Parent.Touched:connect(function(hit)
	if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
		local Lives = plr.leaderstats.Souls;
		local Stage = plr.leaderstats.Stage;
		local Time = plr.leaderstats.Time;
        Lives.Value = 25 
		Stage.Value = 0
		Time.Value = 0

	end
end)

1 answer

Consider changing to GetPlayerFromCharacter as follows:

function hit(hitter)
if hitter.Parent:FindFirstChild("Humanoid") then
local plr = hitter.Parent:GetPlayerFromCharacter()

--You can do the lives and other stats here 

end
end

script.Parent.Touched:connect(hit)

Hope this helped

1 comment

0

I tried this and it didn't work.

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