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
5 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 — 5y

2 answers

Log in to vote
2
Answered by
Elixcore 1337 Moderation Voter
5 years ago
Edited 5 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 — 5y
0
ummm you can change the next to pairs robloxsario 76 — 5y
0
yes you can. Elixcore 1337 — 5y
Ad
Log in to vote
2
Answered by 5 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