Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

how to teleport a npc with a tool ?

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

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)

1 comment

0

does i need to put it in a localscript or a normal script ?

This discussion is preserved as it was. New answers, comments, and votes are closed.