How can I tell who pressed a button?
For example:
script.Parent.MouseButton1Click:Connect(function() print("{player who pressed the button's name} has pressed the button") game.Players.{player who pressed the button's name}.leaderstats.Cash.Value = 100 end)
script.Parent.MouseClick:Connect(function(plr) -- plr print(plr.Name.." has pressed the button") plr.leaderstats.Cash.Value = 100 end)
It's quite simple actually! You don't need to add "game.Players" In fact all yo need to do is add a variable in the function parameters.
Here is the code:
script.Parent.MouseButton1Click:Connect(function(plr) print(plr.. " has pressed the button")
plr.leaderstats.Cash.Value = 100
end)