My teleport Player script not working

Hello, my teleport player script is not working. I have tried for a while to fix this issue but it is not being resolved. So here is my script, can anyone help me fix it?

			player.Character.HumanoidRootPart.CFrame = game.Workspace.WaitingRoom.WaitingSpawn.CFrame + Vector3.new(0,5,0)
		end
2 Likes

Since a player’s character is a model you should use Model:SetPrimaryPartCFrame.

2 Likes

In the code the equals sign is now red and here is my code.

			 Model:SetPrimaryPartCFrame = game.Workspace.WaitingRoom.PiggyWaitingSpawn.CFrame + Vector3.new(0,5,0)
		end
1 Like

replace Vector3.new() with CFrame.new()

1 Like

Because SetPrimaryPartCFrame is a built in function that uses a CFrame as a parameter.

model:SetPrimaryPartCFrame('CFrame Info Here')

you cant add Vector values with CFrame

so you would have to do

player.Character.HumanoidRootPart.CFrame = game.Workspace.WaitingRoom.WaitingSpawn.CFrame + CFrame.new(0,5,0)

Dont add an end if you dont have a function within your code

1 Like

Please check your code since it will infact error when you use CFrame.new(0,5,0) since you are not giving it a proper Vector3 Value. Using Vector3.new(0,5,0) works fine.

My code did not work and its kind of confusing because i’m suppose to use vector3.new so what should my code be?

1 Like

I tested your original code and that works fine. The issue isn’t in the code you provided.

Well what i’m doing is turning a player into a model and then teleporting that model to a position.

1 Like

Can I see your full script? Otherwise, I have no clue how to help.

You do not need to use SetPrimaryPartCFrame for this purpose. Moving the HumanoidRootPart alone is fine as it is already the PrimaryPart of a normal ROBLOX character rig.

1 Like

The player is already a model. The player’s actual, physical body is already a model with the primary part being the HumanoidRootPart.

Therefore, you can teleport it using :MoveTo(). It basically moves the player; that is exactly what it is for.

Developer API Link:

1 Like

Ok, here is my full script, I am using an AlvinBlox script because I just started scripting.

	local character = game.ServerStorage.Piggy:Clone()
	character.Name = piggy.Name
	piggy.Character = character
	character.Parent = workspace
end


function module.TeleportPiggy(player)
	if player.Character then
		
		
		player.Character.Humanoid.WalkSpeed = 18
		player.Character.Humanoid.JumpPower = 15
		
		local bat = game.ServerStorage.Tools.PiggyBat:Clone()
		bat.Parent = player.Character
		if player.Character:FindFirstChild("HumanoidRootPart") then
			 player.Character.HumanoidRootPart.CFrame = game.Workspace.WaitingRoom.WaitingSpawn.CFrame + CFrame.new(0,5,0)
		end
1 Like

Make sure the model has a primary part set

Nothing against using script tutorials, but why ask the DevForum? Alvin’s videos are sure to work as he tests them frequently. The correct answer is already in the video.

1 Like

I have tried to fix my error many times but its just not working so i’m trying to find it out on the dev forum.

How do I set a primary part? (30 characters)

1 Like

Select the model, and go to the Properites. PrimaryPart can be set as an Object.

Go to the model (aka Piggy) and select its PrimaryPart in properties. Then select it to be HumanoidRootPart

1 Like