#Leaderstat not working

1 messages · Page 1 of 1 (latest)

mint dome
#

i can either SS or send you my script when i click my clicks button it doesnt update on my ClicksDisplay

cursive meteor
#

Just post the script here, buddy.

#

Use the code block feature .

mint dome
#

game.Players.PlayerAdded:Connect(function()
local leaderstats = Instance.new('Folder', player)
leaderstats.Name = 'Leaderstats'

local clicks = Instance.new('IntValue', leaderstats)
clicks.Name = 'Clicks'
clicks.Value = 0

end)

#

its nothing big but its the firstg thing im attempting on my own

cursive meteor
#

Lol yeah I figured.

mint dome
#

thats my ClicksDisplay

cursive meteor
#

so, Try setting the folders name into leaderstats in lowecase

mint dome
#

okay

cursive meteor
#

lowercase

mint dome
#

didnt work

mint dome
cursive meteor
#

Sure.

mint dome
#

its a local script also

#

script.Parent.MouseButton1Click:Connect(function()
local plr = game.Players.LocalPlayer
local clicks = plr:WaitForChild('leaderstats'):WaitForChild('Clicks')

clicks.Value = clicks.Value + 1
script.Parent.Parent.TextLabel.Text = clicks.Value

end)

cursive meteor
#

Where is the local script located

mint dome
#

inside of the text button

#

aka my ClicksButton

cursive meteor
#

So startergui.

mint dome
#

yes

cursive meteor
#

what about the first script

#

So there isnt a leaderboard right

mint dome
#

no its supposed to go to here

cursive meteor
#

Can you see your own stats

#

In the leaderborad

mint dome
#

no

#

let me show u sim

#

sum\

cursive meteor
#

There are 2 problems here

mint dome
#

when i test play

#

it doedsnt even show leaderstats in my thingy

cursive meteor
#

Yeah thats probably because

#

The first script is not running

#

is it a local script

mint dome
#

so i need to move it to a script?

#

not local

cursive meteor
#

Ok good

#

Where is it located

mint dome
#

the local?

errant wadiBOT
#

studio** You are now Level 2! **studio

cursive meteor
#

No, the server

mint dome
#

thats all of it

cursive meteor
#

ah, that figures

mint dome
#

huh

cursive meteor
#

you forgot to define player

#

in the first script

#

secondly

mint dome
#

oops

cursive meteor
#

on the local button script

mint dome
#

yes

cursive meteor
#

you should use tostring() on the number value

#

because AFAIK you cant set a text to an number

mint dome
#

okay

cursive meteor
#

K, now playtest and tell me the results

mint dome
#

will do

#

does this look right

#

script.Parent.MouseButton1Click:Connect(function()
local plr = game.Players.LocalPlayer
local clicks = plr:WaitForChild('leaderstats'):WaitForChild('Clicks')

clicks.Value = clicks.Value + 1


script.Parent.Parent.TextLabel.Text = tostring(clicks.Value)

end)

mint dome
#

ok

#

it worked lol ty

cursive meteor
#

no problem

versed ruin
#

It works only for you, however other people wont see any change in the leaderboard since that script changes the clicks value on the clients side instead of the server. That means, you may see whatever amount you clicked, others see 0.

versed ruin
#

To fix that, add a remote function in prefferably ReplicatedStorage and let a server script listen to that remote

#

and then change it via the server script

#

May I fix the scripts for you? May take a while because im on mobile

#

and if you have any questions about the script just ask

mint dome
#

yeah

#

that would be greatly appreciated

versed ruin
#

Alr then give me a few

mint dome
versed ruin
#

pretty confident about it ig

#

sorry for the wait I did this on my phone

mint dome
#

nah its all good no rush

versed ruin
#

Step 1: Replace your leaderstats script with this:

game.Players.PlayerAdded:Connect(function(plr)

if not plr:FindFirstChild(“leaderstats”) then
local leaderstats = Instance.new(“Folder”)
leaderstats.Name = “leaderstats”
leaderstats.Parent = plr
end

if not leaderstats:FindFirstChild(“Clicks”) then
local clicks = Instance.new(“NumberValue”)
clicks.Parent = leaderstats
clicks.Name = “Clicks”
end

end)

Step 2: Place a REMOTE EVENT in REPLICATED STORAGE and call it “updateClicks”

Step 3: Replace your local script with this:

local clickAmount = INSERT AMOUNT
script.Parent.MouseButton1Click:Connect(function()

local player = game.Players.LocalPlayer

game.ReplicatedStorage:FindFirstChild(“updateClicks”):FireServer(clickAmount)

end)

Step 4: Add a new SERVER script in ServerScriptService and insert this script:

game:GetService(“ReplicatedStorage”):FindFirstChild(“updateClicks”).OnServerEvent:Connect(function(player, clickAmount)

player:FindFirstChild(“leaderstats”):FindFirstChild(“Clicks”).Value = player:FindFirstChild(“leaderstats”):FindFirstChild(“Clicks”).Value + clickAmount

end)

#

lmk if there are any errors

#

or if it works

mint dome
#

loading back in studio now ill lyk

#

read lines ok? @versed ruin

#

i got it it works 🙂

versed ruin
#

shit mb

#

U got it tho right?

mint dome
#

oh wait

errant wadiBOT
#

studio** You are now Level 3! **studio

mint dome
#

somewhat

versed ruin
#

alr let me fix it, i see why it isnt working

mint dome
#

it works on top right but not where i want it to go

versed ruin
#

wym?

mint dome
#

i was trying to get

#

this where it shows your clicks

versed ruin
#

ooooh lol

mint dome
#

sorry if i didnt like make that known lo

versed ruin
#

let me implement that rq I didnt know

#

dw

mint dome
#

the game idea i have is every click rewinds or speeds up a frozen moment in time ur stuck in a time loop and your clicking unfreezes objects reveals secrets and eventually breaks reality over and over

#

sum like that

#

havnt decided lol itll bea long time

versed ruin
#

If ur a beginner, I should warn you about starting big projects immediately

mint dome
#

right now i wann just make a super simple thing and see how it goes

versed ruin
#

heres the entire instruction again, im kinda too lazy to send singular

#

Step 1: Replace your leaderstats script with this:

game.Players.PlayerAdded:Connect(function(plr)

if not plr:FindFirstChild(“leaderstats”) then
  local leaderstats = Instance.new(“Folder”)
  leaderstats.Name = “leaderstats”
  leaderstats.Parent = plr

if not leaderstats:FindFirstChild(“Clicks”) then
   local clicks = Instance.new(“NumberValue”)
   clicks.Parent = leaderstats
   clicks.Name = “Clicks”
  end

end

end)

Step 2: Place a RemoteEvent in ReplicatedStorage and call it “updateClicks”

Step 3: Replace your local script with this:

local clickAmount = INSERT AMOUNT
local currentAmount = 0

script.Parent.MouseButton1Click:Connect(function()

currentAmount = currentAmount + 1
 script.Parent.Text = tostring(currentAmount)

local player = game.Players.LocalPlayer

game.ReplicatedStorage:FindFirstChild(“updateClicks”):FireServer(clickAmount)

end)

Step 4: Add a new server script in ServerScriptService and insert this script:

game:GetService(“ReplicatedStorage”):FindFirstChild(“updateClicks”).OnServerEvent:Connect(function(player, clickAmount)

player:FindFirstChild(“leaderstats”):FindFirstChild(“Clicks”).Value = player:FindFirstChild(“leaderstats”):FindFirstChild(“Clicks”).Value + clickAmount

end

mint dome
#

trying no

#

now

#

okay now neither works lol

#

i dont evne have a leaderstats folder anymore when test playing

versed ruin
#

😐

mint dome
#

that seems like i did a stupid mistake lol

versed ruin
#

atp just ask chatgpt to fix it for you what I gave you but Ima head to sleep now bc its 4 am

#

sorry