The issue occurs occasionally, and I cannot find a way to fix it
local HRP_OFFSET = Vector3.new(0, 1, 0)
local function ChooseATeleporter(): BasePart
if (minigame_model and minigame_model:FindFirstChild("Teleporters")) then
return table.remove(minigame_teleporters_array, math.random(#minigame_teleporters_array)) :: BasePart
else
error("There are no models in workspace with that name or there is no teleporters folder")
end
end
--Teleport the player from NotInGame to a random Teleporter
for _, player: Player in table.clone(player_handler.PlayersNotInGame) do
--Move players from NotInGame array into InGame array
if not player.Character then
continue
end
local hrp = ((player.Character):FindFirstChild("HumanoidRootPart") :: BasePart)
hrp.Anchored = true
hrp.CFrame = CFrame.new(ChooseATeleporter().Position + HRP_OFFSET,minigame_model:FindFirstChild("OriginPoint").Position)
hrp.Anchored = false
end
Even when I increase the HRP_OFFSET Y Axis, it still happens, I tried to anchor and unanchor the hrp , but the issue is still there
I would guess that it’s an issue with the model rather than the script. You could try adding a part to where the position is set to teleport the player to and check.
for _, player: Player in table.clone(player_handler.PlayersNotInGame) do
--Move players from NotInGame array into InGame array
if not player.Character then
continue
end
local hrp = ((player.Character):FindFirstChild("HumanoidRootPart") :: BasePart)
hrp.Anchored = true
local target = CFrame.new(ChooseATeleporter().Position + HRP_OFFSET,minigame_model:FindFirstChild("OriginPoint").Position)
local debugPart = Instance.new("Part")
local highlight = Instance.new("Highlight", debugPart)
--set highlight to always on top, i forgot what the property was called
debugPart.Size = Vector3.new(2, 2, 1)
debugPart.Anchored = true
debugPart.CFrame = target
debugPart.Name = tostring(player)
debugPart.Parent = workspace
hrp.CFrame = target
hrp.Anchored = false
end
something like this and check where the script positions them
I found the issue.
I am cloning the map from ServerStorage (then Parenting to workspace) and then teleporting the characters.
However, sometimes the players get teleported to the Part before the map has time to be loaded