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 :)
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)
Thanks Formidable_Beast, HilyrHere and Phlegethon5778 For Answering, Ive Solved The Problem, Thanks!!