What I'm doing is create a part with a clickdetector in it. I am then creating a script inside of the clickdetector that registers when the player clicks the part and gives them oh-so much money, 500 for example.
I don't want to include my failure scripts here as I would only be embarrassed. I'm also pretty sure that I will need a completely new script and I am going in the opposite direction.
Edit: The ClickDetector Script was not working because I forgot the bracket at the end. It should be fine now.
Don't be afraid to put your scripts on Scripting Helpers, as we are all here for a reason, whether as askers or answerers. To make this, you would simply connect a function to the MouseClick event of ClickDetectors.
script.Parent.MouseClick:Connect(function() -- code end
The first parameter is the player who clicked it. From there, you can go to the player's leaderstats and add 500 to the value named "Money".
Put inside ClickDetector
script.Parent.MouseClick:Connect(function(player) -- player that clicked. It comes with the event. if player:FindFirstChild("leaderstats") and player.leaderstats:FindFirstChild("Money") then player.leaderstats.Money.Value = player.leaderstats.Money.Value + 500 -- add 500 to money. end end) -- I forgot the bracket here.. my bad.
This is assuming that there is already a value inside the player named "leaderstats" and inside that, there is a value named "Money" If not, then put this script inside ServerScriptService.
game.Players.PlayerAdded:Connect(function(player) local l = Instance.new("Folder") l.Name = "leaderstats" local m = Instance.new("IntValue") m.Name = "Money" m.Parent = l l.Parent = player end)
I think this should work.
game.Players.PlayerAdded:connect(function(plr) local s = Instance.new("Folder", plr) s.Name = "leaderstats" local c = Instance.new("IntValue", s) c.Name = "Cash" c.Value = 0 script.Parent.ClickDetector.MouseClick:connect(function() c.Value = c.Value + 500 end) end)
Insert a part, put this script in it. Make sure it features a ClickDetector.