Problem with NPC CFrame

I’m currently having a problem with teleporting 2 NPCs to a certain position. What I’m trying to do is teleport one NPC to the right side of the player like 4 studs forward, and the same thing for the other NPC but on the other side. It worked fine earlier today, but all of a sudden it just broke. I started experimenting with it, I removed everything from the workspace but the sounds and it worked, then I added them back and removed them again and now it’s completely bugged. I only started modifying the script after doing all of that, so it couldn’t be something to do with the script. (I think?)

I would really appreciate if someone could help me with this (and explain what happened) because I can’t seem to figure this out. Here’s the script:

local plrs = game:GetService("Players")

plrs.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		if msg == "you're fatherless" or msg == "You're fatherless" or msg == "fatherless child" then
			local chat = game:GetService("Chat")
			local ss = game:GetService("ServerStorage")
			local fatherFigure = ss:WaitForChild("Father")
			local motherFigure = ss:WaitForChild("Mother")
			local char = plr.Character
			local rootpart = char:WaitForChild("HumanoidRootPart")
			rootpart.Anchored = true
			wait(3)
			workspace.Sounds.arena:Play()
			fatherFigure.Parent = workspace
			fatherFigure.HumanoidRootPart.CFrame = CFrame.new((rootpart.CFrame.LookVector*15+rootpart.CFrame.RightVector*6),char.Head.Position - Vector3.new(0,3,0)) + Vector3.new(0,2.7,0)
			wait(3)
			workspace.Sounds.arena2:Play()
			motherFigure.Parent = workspace
			motherFigure.HumanoidRootPart.CFrame = CFrame.new((rootpart.CFrame.LookVector*15-rootpart.CFrame.RightVector*6),char.Head.Position - Vector3.new(0,3,0)) + Vector3.new(0,2.7,0)
			wait(3)
			chat:Chat(fatherFigure.Head, "Me and Mother Figure are going to the shop.",Enum.ChatColor.White)
			chat:Chat(motherFigure.Head, "Me and Father Figure are going to the shop.",Enum.ChatColor.White)
			wait(3)
			plr.PlayerGui.GameplayUI.BlackScreen.Visible = true
			wait(1.75)
			workspace.Sounds["Divine Intervention"]:Play()
			plr:Kick("You died because you were a fatherless child 💀")
		else
			print("Child is not fatherless")
		end
	end)
end)

There are no errors or anything printed in console, what happens is that the NPCs are not teleporting to the CFrame of my HumanoidRootPart, but they do go to the sides.

1 Like

Your’e script works fine for me.

But I did have to remove the following lines:

			#14 --workspace.Sounds.arena:Play()
			#18 --workspace.Sounds.arena2:Play()
			#25 --plr.PlayerGui.GameplayUI.BlackScreen.Visible = true
			#27 --workspace.Sounds["Divine Intervention"]:Play()
			#28 --plr:Kick("You died because you were a fatherless child 💀") -- because it annoyed me :grinning:

For the Dummy I just copied my own character and put two copies in Server Storage then named one Mother and one Father.

Maybe your NPC is the problem.

2 Likes

It could be something in Workspace or could be the NPCs because it just broke itself without me modifying it at all, and also when I put the exact same script into another game it works fine.

I ended up fixing it by using :PivotTo(). Turns out it’s actually really useful

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.