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

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

Asked by 7 years ago

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

Log in to vote
0
Answered by 7 years ago

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

0
I tried this and it didn't work. SocialENTRcoRSE 21 — 7y
Ad

Answer this question