Mhmm, still not working for me.
game.Players.PlayerAdded:Connect(function(plr)
local leaderstats = Instance.new(âFolderâ, plr)
leaderstats.name = âleaderstatsâ
local cash = Instance.new(âIntValueâ, leaderstats)
cash.Name = âCashâ
cash.Parent = leaderstats
cash.Value = 0
end)
This is my leaderboard script.
can your provide your code? Your part script as well? Using this `````` This way we can help and itâs readable.
Ok here is my leaderboard script under server storage.
local leaderstats = Instance.new(âFolderâ, plr)
leaderstats.name = âleaderstatsâ
local cash = Instance.new(âIntValueâ, leaderstats)
cash.Name = âCashâ
cash.Parent = leaderstats
cash.Value = 0
end)
Here is the script that gives the cash when the user touches the part:
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if db == false then
db = true
script.Parent.Transparency = 1
script.Parent.CanCollide = false
player.leaderstats.cash.Value = player.leaderstats.cash.Value + 50
wait (3600)
script.Parent.Transparency = 0
script.Parent.CanCollide = true
db = false
end
end
end)
I sent the code here to you, take a look.
I sent the code here to you, take a look at it.
Make sure you leaderboard is under âServerScriptServiceâ not ServerStorage.
You donât define what (plr) is. Also Name needs to be capitalised.
What needs to be in capital letters?
Nvm, I thought I saw name in Capitals. Does everything work fine now?
No, it still is not working for me.
Are the leaderstats working or just the brick isnât working?
Try this:
script.Parent.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
local leaderstats = plr.leaderstats
local money = leaderstats.Cash
local db = false
if plr then
if db == true then
db = false
money.Value += 100 -- change
wait(3600)
db = true
end
end
end)
Ok, will do bro. Hopefully it works, fingers crossed. Is that the touch script?
Yes it is, let me know if it didnât work.
Also, do I need a variable that holds my part? Like a variable that is like game.Workspace.CashBlock or something?
No, script.parent defines that the script is in the part. So you shouldnât have to do change anything.
Does not work for me, sadly I think there needs to be a condition that sees if the user steps on the block like if hit.Parent === then.
script.Parent.Touched does that, I donât think thatâs the problem. Anything in the output?
Here is my leaderboard script again:
local leaderstats = Instance.new("Folder", plr)
leaderstats.name = 'leaderstats'
local cash = Instance.new("IntValue", leaderstats)
cash.Name = 'Cash'
cash.Parent = leaderstats
cash.Value = 0
end)