Hey guys! I hope y’all doing very very well! Being direct, I’m using Region3 to make a PlayerCount, and I want to show in a Gui that PlayerCount, the problem is that when I’m trying to pass the PlayerCount to the TextLabel, it gives me that error that you can see in the title:
Here’s the Region3 script (ServerScript):
local debounce = false
local playerfound = false
function CreateRegion3FromPart(Part)
return Region3.new(Part.Position-(Part.Size/2), Part.Position+(Part.Size/2))
end
function GetPlayersInPart(part)
local region = CreateRegion3FromPart(part)
local partsInRegion = workspace:FindPartsInRegion3(region,nil,math.huge)
local Players = {}
local PlayerCount = 0
for i, Part in pairs(partsInRegion) do
local player = game.Players:GetPlayerFromCharacter(Part.Parent)
if player then
for i, v in pairs(Players) do
if Players[i].Name == player.Name then
playerfound = false
end
end
if playerfound == false then
table.insert(Players,player)
PlayerCount = PlayerCount + 1
end
playerfound = false
end
end
for i, v in pairs(Players) do
game.ReplicatedStorage.RemoteEvents.ChangeCMPlayerCount:FireClient(Players[i], PlayerCount)
end
return Players
end
while wait(1) do
GetPlayersInPart(game.Workspace.TeleportPlace.CompleteFullMatches.CMRegion)
end
Here’s the Client Event script (LocalScript):
game.ReplicatedStorage:WaitForChild('RemoteEvents').ChangeCMPlayerCount.OnClientEvent:Connect(function(player, PlayerNames, PlayerCount)
local player = game.Players.LocalPlayer
local playersInRegion = PlayerCount
player:WaitForChild('PlayerGui').HowManyPlayersIn.PlayerCount.TextLabel.Text = "Players: "..playersInRegion.."/12"
end)
I don’t know really what can be messing the script in here, so if you can give me a hand with this, even if it’s the smallest one, I’ll appreciate it a lot! Thank you for everything and have a nice day! bye!