Can't Move Player

Hey guys, Army here!

This is a follow-up to my last post, How To Move Character With Code? where It ended on moving the Basepart of the character to move it. However, when I tried this, It gave me 2 errors.

  1. exception while signaling: Cannot Teleport in the Roblox Studio.
  2. Basepart is not a valid member of Model “Workspace.XXXArmyKittenzXXX”

(Note: Workspace.XXXArmyKittenzXXX is my player model)

The code I used to attempt moving the player
local LocalPlayer = game.Players.LocalPlayer
local Character = game.Workspace:WaitForChild(LocalPlayer.Name)
local Hum = Character:WaitForChild("Humanoid")

-- Defines the PLayer, Character, and Humanoid

local Animation = Hum:LoadAnimation(script:WaitForChild("Animation"))

--Loads Animation

wait(3)

Animation:Play()

local CharBasePart = Character.Basepart
wait(2)

CharBasePart.Position += Vector3.new(0,10,0)

I don’t know what I’m doing wrong, and I don’t know any alternates, as my objective was to tween the player. (This was just a test run.)

Any advice would be helpful, and thank you for your time! (Anyone pls)

1 Like

I see your issue. You used Local CharBasePart = Character.Basepart. That would only work if you have a part named ‘Basepart’ in the character model. If you want to cache the PrimaryPart directly you can add this somewhere after you cache the character. local CharPrimaryPart = Character.PrimaryPart

Try using this.

local LocalPlayer = game.Players.LocalPlayer
local Character = game.Workspace:WaitForChild(LocalPlayer.Name)
local Hum = Character:WaitForChild("Humanoid")

-- Defines the PLayer, Character, and Humanoid

local Animation = Hum:LoadAnimation(script:WaitForChild("Animation"))

--Loads Animation

task.wait(3)

Animation:Play()

task.wait(2)

Character:SetPrimaryPartCFrame(Character.PrimaryPart.CFrame * CFrame.new(0,10,0))

I believe this should fix your 2nd error, your first one is just because you have some script trying to teleport you to another place. I also suggest looking at Model | Roblox Creator Documentation, it has an in-depth explanation.

1 Like