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

Unable To Cast Array Int64 ??

Asked by 6 years ago

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

0
You can only use :IsInGroup on one group at a time. User#25115 0 — 6y
0
Also, .Value is not a valid member of a Boolean. :IsInGroup returns a boolean value, that is it. User#25115 0 — 6y
0
Also, you cannot put an array into the :GetPlayerByUserId, it only expects one UserId. User#25115 0 — 6y
View all comments (2 more)
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. HilyrHere 79 — 6y
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! Yokohane 50 — 6y

2 answers

Log in to vote
0
Answered by 6 years ago

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)

0
Hm so what should i change it into?? Yokohane 50 — 6y
0
Also dude any idea with the Regiment.Value thing? I think it has problem as well Yokohane 50 — 6y
0
Nvm bro I solved both problems, anyway, thanks for answering! Yokohane 50 — 6y
Ad
Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

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

Answer this question