Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

-- 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

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.