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)
You'll want to add your previously amount + 1
local Money = Players:GetAttribute("Coin")
Players:SetAttribute("Coin", Money+1) -- Add Money + 1
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.