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

Why wont this model go into workspace with a position?

Asked by 5 years ago

Ok so i have this script and for some reason it doesn't teleport to it's position ;/

My attempt

game.ReplicatedStorage:WaitForChild("js").OnServerEvent:Connect(function(plr,pos)
    local r = game.ServerStorage.npc:Clone()
    r.Parent = workspace
    workspace:WaitForChild(r).UpperTorso.CFrame = pos
end)

Here's what happens Client send's a cframe value in remote Servers clones the npc and parents it to workspace server positions it to the pos -- This is where my error is at it wont position it ;/

0
Show the position parameter to us, and is there any error on the output? and it's WaitForChild("r"). MArzalAlBuchariZ 33 — 5y

1 answer

Log in to vote
2
Answered by 5 years ago
Edited 5 years ago

Change line 4 at this:

r.UpperTorso.CFrame = CFrame.new(pos)

So if you are using CFrame, you have to return a CFrame value and not a position value. CFrame.new changes a position into a CFrame.

Also, if you want to move the entire ncp, you have to change his HumanoidRootPart's CFrame and not his UpperTorso's CFrame:

r.HumanoidRootPart.CFrame = CFrame.new(pos)

Note: you don't need to get the cloned npc again from the workspace, just use his variable. Hope this helped!

0
Thank you i almost quit my game and i would of been homeless you changed a life think about that! fistter1 88 — 5y
Ad

Answer this question