Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Moving the position of the player after firing a client?

I'm trying to make it so after a client has been fired and the screen fades out, the player moves to a different position before fading back in. I figured out how to make a fade but the moving player i'm having trouble with. I've used many different scripts but none seem to be working.

I'm using a local script that is placed inside the PlayerGUI.

If anyone could help that would be great!

2 comments

0

You should handle all teleportation on the server because if a local script is used to teleport a player, the player would appear teleported only to itself, and not to other players

0

Also, I would recommend using the SetPrimaryPart function to teleport players

1 answer

This will teleport the player after re-spawning to 0,100,0. Just tested, works for me.

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local function onCharacterAdded(character)
    local player = Players:GetPlayerFromCharacter(character)
    -- Teleport the player there when their HumanoidRootPart is available
    local hrp = character:WaitForChild("HumanoidRootPart")
    -- Wait a brief moment before teleporting, as Roblox will teleport the
    -- player to their designated SpawnLocation (which we will override)
    RunService.Stepped:wait()
    hrp.CFrame = CFrame.new( Vector3.new(0, 100, 0))
end

local function onPlayerAdded(player)
    player.CharacterAdded:Connect(onCharacterAdded)
end

Players.PlayerAdded:Connect(onPlayerAdded)

Read more at Developer wiki, here

This discussion is preserved as it was. New answers, comments, and votes are closed.