#how do i use leaderstats

28 messages · Page 1 of 1 (latest)

marsh idol
#

im trying to use leader stats and no tutorials work for me i can create a leader stats but i cant modify the data
the script provided is the only 1 all it does, the leader board script and the potato script just lets you click a potato after 20 seconds and i wanna make it that when you click it it gives you 1 potato point

vocal remnant
#

You should have your script trigger a remote event and a server script for event listening and change the leaderboard from there.

marsh idol
#

thre both serverscripts

#

or well scripts

vocal remnant
# marsh idol or well scripts

if player:FindFirstChild("leaderstats") then
local potatoScore = player.leaderstats:FindFirstChild("PotatoScore")
if potatoScore then
potatoScore.Value = potatoScore.Value + 1

marsh idol
#

whould i put this under if timesgrew ==4 then?

#

thank you for the script too

vocal remnant
#

Same place

marsh idol
#

whre in the script

#

im not good at this

vocal remnant
#

Probably after print()

marsh idol
#

thx

vocal remnant
#

You also need to add player into function() “function(player)”

marsh idol
#

it created more errors ): local TimesGrew = 0
local playerstats = 0
local poratoscore = 0
local potato = workspace.potato
local PotatoClicked = potato.ClickDetector
local originalPosition = potato.CFrame -- useless varible stuff

PotatoClicked.MouseClick:Connect(function()
if TimesGrew ==4 then
poratoscore = poratoscore+1
print(poratoscore)
if player:FindFirstChild("leaderstats") then
local potatoScore = player.leaderstats:FindFirstChild("PotatoScore")
if potatoScore then
potatoScore.Value = potatoScore.Value + 1
TimesGrew = 0
potato.CFrame = originalPosition
endend

while true do
wait(5) -- distance from the potato stages
if TimesGrew < 4 then
potato.CFrame = potato.CFrame * CFrame.new(0, 1, 0)
TimesGrew = TimesGrew + 1

        end
    end
white bisonBOT
#

studio** You are now Level 1! **studio

vocal remnant
#

This will communicate to your server script what player in pressing it

marsh idol
#

thank you

#

ill test it bvut i dont know if it work

#

it dont work

#

this is the leaderboard script
local Players = game:GetService("Players")

local function leaderboardSetup(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player

local PotatoScore = Instance.new("IntValue")
PotatoScore.Name = "Gold"
PotatoScore.Value = 0
PotatoScore.Parent = leaderstats

end

-- Connect the "leaderboardSetup()" function to the "PlayerAdded" event
Players.PlayerAdded:Connect(leaderboardSetup)

#

and i used chat gpt for this script local TimesGrew = 0
local poratoscore = 0
local potato = workspace.potato
local PotatoClicked = potato.ClickDetector
local originalPosition = potato.CFrame

PotatoClicked.MouseClick:Connect(function(player)
if TimesGrew == 4 then
poratoscore = poratoscore + 1
print(poratoscore)
if player:FindFirstChild("leaderstats") then
local potatoScore = player.leaderstats:FindFirstChild("PotatoScore")
if potatoScore then
potatoScore.Value = potatoScore.Value + 1
end
end
TimesGrew = 0
potato.CFrame = originalPosition
end
end)

while true do
wait(5) -- distance from the potato stages
if TimesGrew < 4 then
potato.CFrame = potato.CFrame * CFrame.new(0, 1, 0)
TimesGrew = TimesGrew + 1
end
end

#

nvm i got it to work THANK YOU SO MUCH

#

solved

shy dirge
#

WHO USES LEADERSTATS

marsh idol
shy dirge
#

@marsh idol

#

CREATE UR OWN UI

#

FOR LEADERBOARD