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

How do I make a teleportation script for my admin panel?

Asked by 3 years ago

I already got the basics down, what I am trying to do now is move the plr's location to be right in front of the target.

script.Parent.MouseButton1Click:Connect(function()

    local plr = game.Players.LocalPlayer
    local targetName = script.Parent.Parent.TextBox.Text
    local target = game.Players:findFirstChild(targetName)
    local human = plr.Character.Humanoid



end)

1 answer

Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

you can take your characters primary part and cframe it to be in front of the targets primary part.

local targetCFrame = target.Character.PrimaryPart.CFrame:ToWorldSpace(CFrame.new(0,0,-5))

plr.Character:SetPrimaryPartCFrame(targetCFrame)

if youre unfamiliar with CFrames, the :ToWorldSpace() basically takes its argument to be the relative displacement from the targets character cframe and outputs corrosponding workspace cframe for you to use for positioning your character. i made it to be 5 units in front of the target, but you can play with that number to be whatever you like

Ad

Answer this question