I am new on the coding and I keep getting a message saying: "attempt to perform arithmetic (add) on userdata and number"
local Price = 20 local MoneyValue = game.ServerScriptService.CurrencyRiser:WaitForChild("amount") script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player.leaderstats.Cash.Value >= Price then player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - Price MoneyValue = MoneyValue + 1 script.Parent:Destroy() end end end)
how to i fix this error?
Try this:
local Price = 20 local MoneyValue = game.ServerScriptService.CurrencyRiser:WaitForChild("amount").Value -- You didn't put .Value, it should fix it. script.Parent.Touched:Connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player.leaderstats.Cash.Value >= Price then player.leaderstats.Cash.Value = player.leaderstats.Cash.Value - Price MoneyValue = MoneyValue + 1 script.Parent:Destroy() end end end)