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

Unable To Cast Array Int64 ??

game.Players.PlayerAdded:Connect(function(player)

local PlayerInMoreThanAGroup = {733857232, 88849958}

if game.Players:GetPlayerByUserId(PlayerInMoreThanAGroup) ~= nil then
			
		Regiment.Value = "MP+"..player:IsInGroup(4510669, 4560842, 4560830, 4561186, 4560837, 4561172).Value
		Rank.Value = player:GetRoleInGroup(4510669)
	
end

end)

So i have this script that gets the player userId when the player enters the game. Then if the player userId in the table is not equal to nil then it will do the following function.

Im also sure that theres also something wrong with the Regiment.Value, basically i was trying to change the Regiment.Value if the player is in more than one group(groupId above) like for example u are in a group called Military Police and another group called Special Forces then the Regiment.Value will be MP+1, Meaning Military Police + 1 more group.

Any idea? All the helps will be greatly appreciated :)

6 comments

0

You can only use :IsInGroup on one group at a time.

0

Also, .Value is not a valid member of a Boolean. :IsInGroup returns a boolean value, that is it.

0

Also, you cannot put an array into the :GetPlayerByUserId, it only expects one UserId.

0

You're trying to refer to the whole table which would return the hexademical address of the table and to get the actual values inside of that table you have to do a for loop on it.

0

@Phlegethon5778 Yeah man, I solved it myself, thats exactly what i did, anyway thanks for answering! @HilyrHere Its ok man, I solved it myself, anyway, thanks for answering!

2 answers

✓ Accepted answer

Casting refers to changing a datatype into another. Let's say that you can a variable

local string1 = "Example String"

If you were to attempt to change that variable into a number, or use that variable when a number is expected; lua will cast that variable into a number.

-- Using Vector3 since it only accept numbers

game.Workspace.Part.Position = Vector3.new(string1, string2, string3)

-- Lua would attempt to change the string into a number, which errors since it expects a number

Usually casting error happens when you try to convert a string into a userdata value(say an object)

In your case Lua was converting the array: PlayerInMoreThanAGroup to an int64(a number value)

3 comments

0

Hm so what should i change it into??

0

Also dude any idea with the Regiment.Value thing? I think it has problem as well

0

Nvm bro I solved both problems, anyway, thanks for answering!

Thanks Formidable_Beast, HilyrHere and Phlegethon5778 For Answering, Ive Solved The Problem, Thanks!!

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