Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Moving the position of the player after firing a client?

Asked by 6 years ago

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!

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 theking48989987 2147 — 6y
0
Also, I would recommend using the SetPrimaryPart function to teleport players theking48989987 2147 — 6y

1 answer

Log in to vote
0
Answered by
elomage 12
6 years ago

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

Ad

Answer this question