I want to make it that when a player clicks on an item he gets money in the leaderboard. This is a struggle I am dealing with for quite a while so I can hope you guys can help me. I already have the leaderstats folder which goes as follows
game.Players.PlayerAdded:Connect(function(plr) local f = Instance.new("Folder", plr) f.Name = "leaderstats" local cash = Instance.new("IntValue", f) cash.Name = "Cash" cash.Value = 0 end)
And I have the item which changes when a player clicks on it, here is the code of that:
function Money() script.Parent.Money.Decal1.Transparency = 1 script.Parent.Money.Decal2.Transparency = 1 script.Parent.Money.Transparency = 1 script.Parent.ClickDetector.MaxActivationDistance = 0 script.Parent.Cash.Playing = true wait(60) script.Parent.Money.Transparency = 0 script.Parent.Money.Decal1.Transparency = 0 script.Parent.Money.Decal2.Transparency = script.Parent.ClickDetector.MaxActivationDistance = 10 end script.Parent.ClickDetector.MouseClick:Connect(Money)
But I can't figure out how to give value to the Cash file when the players clicks on the money. I hope I am doing it alright, this is my first time on this site so please be kind, thanks for all the help.

3 comments
the MouseClick event has a built in argument that is the player who clicked, which you can use to access the Cash object
Also, you should refrain from using the second parameter of Instance.new in the future , as using it can have negative effects on performance, due to the way roblox handles property listeners
@theking48989987 , what causes it to drop performance? And I assume you should use the two-line approach of
thing = Instance.new('Part)andthing.Parent = other_thing?