#how do i use leaderstats
28 messages · Page 1 of 1 (latest)
You should have your script trigger a remote event and a server script for event listening and change the leaderboard from there.
if player:FindFirstChild("leaderstats") then
local potatoScore = player.leaderstats:FindFirstChild("PotatoScore")
if potatoScore then
potatoScore.Value = potatoScore.Value + 1
Same place
Probably after print()
thx
You also need to add player into function() “function(player)”
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
** You are now Level 1! **
This will communicate to your server script what player in pressing it
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
WHO USES LEADERSTATS
WHAT AM I MENT TO USE