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

how to teleport a npc with a tool ?

Asked by 6 years ago

Everything is in the title.

Script :

--This code is in a localscript that is inside the tool

local C = game.Workspace["Guest 666"] --The Npc

local P = game.Players.LocalPlayer

local M = P:GetMouse()

script.Parent.Activated:connect(function()
    local H = M.Hit
    C.Torso.CFrame = H
end)

I don't know where is the error and i don't know if i should use a normal script

1 answer

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

Try using this code:

local C = workspace:FindFirstChild("Guest 666")
C.PrimaryPart = C.Torso

local P = game:GetService("Players").LocalPlayer

local M = P:GetMouse()

script.Parent.Activated:connect(function()
    local H = CFrame.new(M.Hit.p) --get rid of rotation
    C:SetPrimaryPartCFrame(H)
end)

0
does i need to put it in a localscript or a normal script ? xJathur95x 129 — 6y
Ad

Answer this question