Whenever I am working with leaderstats, it’s like they don’t even exist!
Please help!
The script:
local currencyName = “Cash”
local clickDetector = script.Parent
local player = game.Players.LocalPlayer
function onMouseClick()
script.Parent.Parent.Top.Fire.Enabled = false
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 1
end
clickDetector.MouseClick:connect(onMouseClick)
Have you created a folder called leaderstats and set its parent to player?
It would also help if you could show your script that is creating this error
posatta
(pasta)
June 2, 2020, 11:14pm
3
The issue isn’t that leaderstats doesn’t exist, it’s that whatever you’re checking .leaderstats for doesn’t exist. Can you show your code? It’s hard to help you without more context.
3 Likes
deluc_t
(Deluct)
June 2, 2020, 11:18pm
4
If you created leaderstats, you can either WaitForChild() or repeat wait() until so the code doesn’t continue until the leaderstats loaded.
You could try GetPlayerFromCharacter()
Did you name the script “leaderstats” or whatever it is supposed to be?
FerbZides
(FerbZides)
June 2, 2020, 11:43pm
7
It is not the fault of leaderstats you should do this server sided so exploiters cant edit your values
Roblox automatically provides the player as a parameter here’s a sample
script.Parent.MouseClick:Connect(function(PartClicked)
local player = PartClicked.Parent
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 1
end)
un1ND3X
(ice)
June 3, 2020, 1:25pm
8
The MouseClick event’s parameter is the player who clicked the ClickDetector, not the character.
script.Parent.MouseClick:Connect(function(player)
player.leaderstats.Cash.Value = player.leaderstats.Cash.Value + 1
end)
1 Like