0

I was trying to make a code that if you touch a coin, then the value of your coins goes up 1 more, but i tried to make and haven't sucess. Here's the code.

script.Parent.Touched:Connect(function(Player)
if Player.Parent:FindFirstChild("Humanoid") then
    local Players = game.Players:GetPlayerFromCharacter(Player.Parent)
    local Money = Players:GetAttribute("Coin")
    Players:SetAttribute("Coin", +1)
    task.wait(.2)
    script.Parent:Destroy()
end end)
takezo
  • 101
  • 7
  • 1
    You should include an error if you are getting one, you code has invalid you should be getting an `unexpected symbol near '+'` error. simply saying "my code doesn't work" but not explaining what that means is not helpful, imagine if you were to get a response equally as vague "yep something is clearly wrong in it" – Nifim Jul 21 '22 at 14:41
  • I know that gives an error, sorry for putting this on code, but i dont know how to make this – takezo Jul 21 '22 at 17:02

1 Answers1

0

You’ll want to add your previously amount + 1

local Money = Players:GetAttribute("Coin")
Players:SetAttribute("Coin", Money+1) -- Add Money + 1
kingerman88
  • 521
  • 3
  • 12