You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve?
I want to achieve a side companion in my game that teleports to the player when it touches a part. The NPC is local, has no collision with the local player and follows the player. -
What is the issue?
He won’t teleport back to me. No matter what. I have tried and tried. Watch the video.
-
What solutions have you tried so far?
What I have tried is usingCharacter:GetPrimaryPartCFrame()
andNoob:SetPrimaryPartCFrame(CFrame)
, which worked but the players CFrame didn’t update.
It goes to where the player spawned at first when the server started.
local camera = workspace:WaitForChild("Camera")
local Noob = camera:WaitForChild("Noob")
local Player = game.Players.LocalPlayer
local PCFrame = game.Workspace:WaitForChild(tostring(Player.Name)).PrimaryPart.CFrame
Noob["Right Leg"].Touched:Connect(function(hit)
if hit.Name == "Sandy Bottom" and hit:IsA("BasePart") then
print("Hit sandy.")
Noob:SetPrimaryPartCFrame(PCFrame)
end
end)
Noob["Left Leg"].Touched:Connect(function(hit)
if hit.Name == "Sandy Bottom" and hit:IsA("BasePart") then
print("Hit sandy.")
Noob:SetPrimaryPartCFrame(PCFrame)
end
end)
I got no errors when the code ran.
How would I fix it? It could be fixed if the PrimaryPart’s CFrame updates in the player’s character. I don’t understand the difference that much of CFrame
and Position
.