Trying to make a script that would give player money when a brick hits another brick. The idea would be a player driving this block into another block. Trying to script this here is what I have made to give an insight into what I'm trying to do.
Thanks
Player = game.Players.LocalPlayer script.Parent.Touched:connect(function(part) Player.leaderstats.Money.Value = Player.leaderstats.Money.Value + 1 end)
What you're doing right now is a bad way of giving money to people.
First of all, you're basically creating an infinite loop of giving the player money because you have no debounces or anything that stops it from running every time it collides with the baseplate, etc. Second of all, you're doing this in a local script (i'm assuming that because localplayer can only be used in a local script) meaning that the changes you make to the money will not be seen by the server and will basically be "fake money".
What you could do instead is this:
--In a server script Part.Touched:Connect(function(hit) local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then plr:WaitForChild("leaderstats").Money.Value = plr:WaitForChild("leaderstats").Money.Value + 1 end end)
You could also add a debounce or a cooldown using wait(seconds) to prevent players from getting like 1000 dollars per second or something.
If this answered your question please mark it as the answer, and comment below if you have any questions.