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

Force teleport players to a Part?

Asked by
Aozwel 71
4 years ago

Hey there, new scripter here

I was wondering how i would go about Force Teleporting players to a certain Part?

Thanks!,

0
Set the player’s cframe to the part’s cframe SmartNode 383 — 4y

2 answers

Log in to vote
2
Answered by
Elixcore 1337 Moderation Voter
4 years ago
Edited 4 years ago
local part = workspace.Part -- Change this

for i,v in next, game.Players:GetPlayers() do -- loop through the players
 local chr = v.Character 
    if chr and chr:FindFirstChild("HumanoidRootPart") then  -- check if they have a character and humanoidrootpart
        chr:SetPrimaryPartCFrame(part.CFrame) -- set their cframe to the part's cframe.
    end
end
1
Thanks! Aozwel 71 — 4y
0
ummm you can change the next to pairs robloxsario 76 — 4y
0
yes you can. Elixcore 1337 — 4y
Ad
Log in to vote
2
Answered by 4 years ago
local PartToTeleportTo = game.Workspace:FindFirstChild("") --// Fill this in with the part name.

for i,v in pairs(game.Players:GetPlayers()) do
    v.Character.HumanoidRootPart.CFrame = PartToTeleportTo.CFrame
end

Answer this question