I have this code which changes the colour of a brick when clicked which works. How do I edit so that it adds cash to a players leaderstats when clicked.
My clickdetector brickcolour code:
game.Workspace.MyClickDetectorEvent.OnServerEvent:Connect(function() script.Parent.Parent.MyPart.BrickColor = BrickColor.Random() end)
Do i change the script.Parent.MyPart BrickColor output to make it adds cash to my leaderboard instead of changing the bricks colour?
I already have a leaderboard in my game with stats called "Cash" so do I have to type FindFirstChild Cash or something...
Thank You and Help is Appreciated
workspace.MyClickDetectorEvent.OnServerEvent:connect(function(plr) plr.leaderstats.Cash.Value = plr.leaderstats.Cash.Value end)
OnServerEvent automatically passes the player as an argument so you can use that to navigate to leaderstats then cash and manipulate it there
Try This:
local credit = true if credit == false then return end if credit = true then script.Parent.OnClicked:connect(function(Onclicked) game.players.localplayer.leaderstats.Cash.Value game.players.localplayer.leaderstats.Cash.Value + 500 end) end --Thank You jamiethegreatQ777 For Making This Script For Aspiringstar346 script.Parent.ClickDetector
If anything Is Wrong (Wich There Wont Be) Message Me On Discord jamiethegreatQ777_Z#0618