This is the current script.
function onTouched() game.Players.Player.Coins.Value = 1 end script.Parent.Touched:connect (onTouched)
Hello,
Your script won't work for a few reasons:
Player isn't a valid Player. You need to use an actual player.
You're setting the Player's coins to 1 every time.
To get a player from the object that touched the brick, you can use the Player's Service :GetPlayerFromCharacter function. Here's how:
local brick = script.Parent local players = game:GetService("Players") brick.Touched:Connect(function(touchedPart) -- Detect when the brick is touched and what part touched it. if players:GetPlayerFromCharacter(touchedPart.Parent) then -- Check if the touched part's Parent is a Player's Character. local plr = players:GetPlayerFromCharacter(touchedPart.Parent) -- Define the player plr.Coins.Value = plr.Coins.Value + 1 -- Add 1 to the player's coins. end end)
Have fun coding!