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

bad argument #2 to '?' (string expected, got table) error?

ServerScriptService.Script:16: bad argument #2 to '?' (string expected, got table)

Commands.addmoney = function(Sender, PlayerGiven, Cash)
game.Players[PlayerGiven].PlayerGui.Panel.Cash.Value=game.Players[PlayerGiven].PlayerGui.Panel.Cash.Value + Cash
end

line 16 is the middle one

1 answer

✓ Accepted answer

Ah yes I see you call Commands:addmoney() which will auto add the field self to the first paramter. Either call Commands.addmoney (without :, only .) or add self to the first paramater. Commands.addmoney(Sender, PlayerGiven, Cash) or

Commands.addmoney = function(self, Sender, PlayerGiven, Cash)
game.Players[PlayerGiven].PlayerGui.Panel.Cash.Value=game.Players[PlayerGiven].PlayerGui.Panel.Cash.Value + Cash
end
-- Now you can call with Commands:addmoney()

(an upvote would be appreciated)

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