Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

What does; "attempt to perform arithmetic on field 'Money' (a userdata value)" mean?

Asked by 7 years ago

-- Sodaghost13

I defined the last two variables last which is why it looks messy :|

I know this is something to do with removing the amount Value and something to do with objects, how else would I take money from one player to donate to the other?

local frame = script.Parent
local imputname = frame:WaitForChild("ImputName")
local imputamount = frame:WaitForChild("ImputAmount")
local confirm = frame:WaitForChild("Confirm")
local playername = imputname:WaitForChild("PlayerName")
local amount = imputamount:WaitForChild("Amount")

confirm.MouseButton1Down:connect(function()
    playername.Value = imputname.Text
    amount.Value = imputamount.Text
    game.Players.LocalPlayer.leaderstats.Money = game.Players.LocalPlayer.leaderstats.Money - amount.Value
    game.Players[playername.Value].leaderstats.Money.Value = game.Players[playername.Value].leaderstats.Money.Value + amount.Value
end)

1 answer

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
7 years ago
game.Players.LocalPlayer.leaderstats.Money - amount.Value

Money is a value object, not a number. You can only do math on a number. What you want is Money's value.

game.Players.LocalPlayer.leaderstats.Money.Value - amount.Value


Also... You need to clean up your code. Use variables to clean it up and shorten everything.

Ad

Answer this question