Using PivotTo() for characters doesnt work sometimes for some players

		for i, player__ in ps:GetPlayers() do
			if player__.Character then
				player__.Character:PivotTo(spleef_map:WaitForChild("SpleefFirstTP").CFrame)
			end
		end

It doesnt pop an error or warning. I didnt understand why it doesnt work for some players while others can teleport easily.

dumb question but does SpleefFirstTP actually exist?

Yes. Even if i assume it gets destroyed in game or smth, script would pop errors because i tried to get nil’s CFrame

do you ever get infinite yeild errors

1 Like

no, i dont get infinite yields

1 Like

do you know anything that happens leading up to the thing not working liek if the player leaves or something

1 Like

they dont leave and i dont think there are certain things that can lead to not teleporting

are you teleporting on the server

yes thats why i use loop for GetPlayers()

have you been able to replicate this at all or does it just happen unexpectedly

i cant control or predict it and i couldnt figure out a pattern about it too so yes, it just happens unexpectedly

what about using player.CharacterAdded:Wait()

im not sure if it would help if you showed more of your script. are you trying to teleport players before they have a chance to actually load in

this might help

i can try but im pretty sure character is loaded at that time. players cant die during game and it had been minutes since the character joined the game and characteradded fired

Try this, i have a similar script that works fine. Plus, it never hurts to add extra checks incase the player isn’t fully loaded.

for i, player__ in ipairs(ps:GetPlayers()) do -- because ipairs() is used for arrays.
		if player__.Character then
			player__.Character:PivotTo(spleef_map:WaitForChild("SpleefFirstTP").CFrame + Vector3.new(0, 2, 0) -- This will ensure that the player doesn't teleport glitched into the tp part.
		end
	end
end

it may sound stupid but is it possible to not using ipairs/pairs cause script to not taking table properly and missing some elements of it?

I don’t understand what you mean. If you are trying to teleport every player to the map i’m sure my method will work.

in luau you rlly don’t have to put ipair or pairs because it automatically picks and it’s the fastest without pais/ipairs.

It’s a long strecth but you can try removing the pairs and see if that stops preventing ppl from bring tped.

I might have confused you i didnt use ipairs/pairs in my code thats why i asked

But yeah that prolly isnt the problem, i will try setting network owner nil and tell if it works or not

1 Like

Firstly, if this is being done on the server, you shouldn’t have to do WaitForChild for the spleef map anymore. Secondly, if PivotTo still doesn’t work, it might be better to try going old-school and just teleporting the HumanoidRootPart of the player’s character instead. You could also use MoveTo as an alternative but that takes a Vector3 Position instead of a CFrame.

It’s also always better and faster to just make a direct reference to the map via a variable instead of making a new reference to it every single time.

local teleportPoint = spleef_map:FindFirstChild("SpleefFirstTP")

if not teleportPoint then
    warn("Teleport point not found.")
    return
end

for _, player in ps:GetPlayers() do
    local character = player.Character

   if not character then
        continue
    end

    local root = character:FindFirstChild("HumanoidRootPart")

    if not root then
        warn("Root not found") -- mainly adding warnings for debugging
        continue
    end

    root.CFrame = teleportPoint.CFrame
end
1 Like