[Lua Issues] attempt to compare string with number

Hello I’ve tried to create a command to change Players skins. I have asked help and we nearly fixed it but then I don’t know what happend.

The issue is line Nr. 35 attempt to compare string with number.

Here is (a part) of the code and issue

		local skinvalue = arguments[2];
		if (skinvalue <= target:SkinCount()) then

if (skinvalue <= target:SkinCount()) then is line Nr. 35

Does anyone know the issue?

Thanks for helping :slight_smile:

Excuse me for being rude but did you even bother reading the error?
“Attempted to compare string with number”
SkinCount() returns a number so obviously skinvalue is set to a string, and you can’t compare a string with a number

One of those values in the if statement is a string, aka text or quotes, as opposed to a raw number - if this is your code, you should know which this is

If you’re certain both ARE numbers, you could encapsulate the value you think is causing the error inside tonumber(value)

if skinvalue => SkinCount() would that make sence?

I want to change a players skin but the skin needs to be a valid skin.

So if the skinvalue is a valid skin to the model then it will change the skin if not a message will pop up that …skinvalue… is not a valid skin.

Commands return a string. Not a number.
You have to convert the string to a number.

local skinvalue = tonumber(arguments[2])

Read the error: ‘tried to compare string with number’

There should be an achievement on FP for writing code on the phone.

Thank you for your help!

[editline]6th April 2016[/editline]

local bodygroup = tonumber(arguments[2]);

if (bodygroup <= target:GetBodygroupCount()) then

the last one is the error

bad argument #1 to ‘GetBodygroupCount’ (number expected, got no value)

I think I need to update arguments[2] to arguments[3]


The function takes one argument:

number bodygroup
The ID of bodygroup to retrieve count of.

You however, suply none.

Argument Nr. 1 The Player that gets target
Argument Nr. 2 The BodyGroup

Ok first of all - Please learn better English, use a translating application, or get a translator to help you, because it’s really difficult communicating like this.

Secondly - What? :v:

So my point is how to fix it

I mean come on dude…

Yes! I would have earned it several times over by now.

@karl-police, if you can’t read error messages then coding is not for you.

The tonumber one I already fixed.

Bodygroup just wants a number and for the number a value or it is first a value and it returns a number.

you’re using the wrong function

[editline]7th April 2016[/editline]

99% of the info you need is only in English. If your English skills aren’t good enough, you can’t code. That’s the harsh truth.

I seperate the functions?

I think the function you’re looking for is called: Ent:GetNumBodyGroups().