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

How do I reset a player's leaderstats with a gui?

Asked by 9 years ago

What I need is a script, that when placed inside a GUI and a player clicks on it, it resets their level.

script.Parent.MouseButton1Up:connect(function()
????.leaderstats.lvl.Value = 0

2 answers

Log in to vote
0
Answered by 9 years ago

Are you trying to have it reset the lvl value on the leaderboard when a player clicks on the button? If so then you will need to add the ButtonClicked() event. If this is a localscript use

player = game.Players.LocalPlayer

as shown in line 1

player = game.Players.LocalPlayer
function onButtonClicked()
player.leaderstats.lvl.Value = 0
end
0
What is the name for lvl is actually uppercase. EzraNehemiah_TF2 3552 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Use a Local Script and MouseButton1Click

script.Parent.MouseButton1Click:connect(function()
local plr = game.Players.LocalPlayer
if plr.leaderstats then
local stat = plr.leaderstats:GetChildren()
for i = 1, #stat do
if stat[i].ClassName == "IntValue" or "NumberValue" then --So you don't need to find names
stat[i].Value = "0" --0
elseif stat[i].ClassName == "StringValue" then
stat[i].Value = "Level 1" --Something like this
elseif stat[i].ClassName == "BoolValue" then
stat[i].Value = false
end
end
end)

Answer this question