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

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

Asked by
v_amp 6
4 years ago

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

Log in to vote
5
Answered by
herrtt 387 Moderation Voter
4 years ago
Edited 4 years ago

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)

Ad

Answer this question