I wanted to make a map picking system that allows players to choose a map to go to. Each map needs 10 players in order to play a different map. But I came across an issue with the player count. When I go to a Teleporter that player count when up by 8 when I am the only player in the teleporter, I went out of the teleporter, the number of player count didn’t decrease. So I tried making it detect only the HumanoidRootPart but the same number when up, I jumped inside the teleporter and it also went up. I’m getting angry, I’m losing my motivation to work on this project.
If you have any solutions please reply down below
Code:
for i,Part in pairs(workspace.Maps:GetChildren()) do
if(Part:IsA("Part")) then
Part.Touched:Connect(function(hit)
if (game:GetService("Players"):GetPlayerFromCharacter(hit.Parent)) then
local player = game:GetService("Players"):GetPlayerFromCharacter(hit.Parent.HumanoidRootPart)
if(Part.Name == "TeleportMagic1") then
if workspace.Maps.TeleportMagic1.Touched:Connect() then
workspace.MapUpVote.Map1.Value = workspace.MapUpVote.Map1.Value + 1
elseif workspace.Maps.TeleportMagic1.TouchEnded:Connect() then
workspace.MapUpVote.Map1.Value = workspace.MapUpVote.Map1.Value - 1
end
elseif(Part.Name == "TeleportMagic2") then
if workspace.Maps.TeleportMagic2.Touched:Connect() then
workspace.MapUpVote.Map2.Value = workspace.MapUpVote.Map2.Value + 1
elseif workspace.Maps.TeleportMagic2.TouchEnded:Connect() then
workspace.MapUpVote.Map2.Value = workspace.MapUpVote.Map2.Value - 1
end
elseif(Part.Name == "TeleportMagic3") then
if workspace.Maps.TeleportMagic3.Touched:Connect() then
workspace.MapUpVote.Map3.Value = workspace.MapUpVote.Map3.Value + 1
elseif workspace.Maps.TeleportMagic3.TouchEnded:Connect() then
workspace.MapUpVote.Map3.Value = workspace.MapUpVote.Map3.Value - 1
end
end
end
end)
end
end
The errors I got was attempt to call a nil value and Attempt to connect failed: Passed value is not a function