Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

bad argument #3 (Vector3 expected, got Object)?

so from my last questions yesterday i was making a titan shift thing from the anime aot. those were just to help me to make a prototype thing to see if i like and i did, but i now will try and improve it. im doing it like other games where it clones a titan model and the character teleports into the nape of the neck. idk if what im trying will put it in the neck but what ever. so while im trying to make the titan clone and teleport to the character, i got and error saying bad argument #3 (Vector3 expected, got Object) here is my script:

local titan = game.ReplicatedStorage:WaitForChild("titan"):Clone()

game.ReplicatedStorage.titanshifted.OnServerEvent:Connect(function(player)
	wait(3)
	script.Parent.transform:Play()
	game.Workspace:FindFirstChild(player.name).HumanoidRootPart.Position = game.Workspace:FindFirstChild(player.name).HumanoidRootPart.Position + Vector3.new(0,25,0)
	titan.Head.Position = game.Workspace:FindFirstChild(player.name).HumanoidRootPart
end)

line 7

sorry if their were spelling mistakes

3 comments

0

At line 7 remember to write titan.Head.Position = Vector3.new

0

all you need to do it add a .Position to the end of line 7

0

it gave no errors but it wont teleport

4 answers

HumanoidRootPart is not a Vector3. It does, however, have the Position property that is a Vector3.

Use

titan.Head.Position = game.Workspace:FindFirstChild(player.name).HumanoidRootPart.Position

Since after you call :Clone() it's not parented to anything, you'll also have to set the parent to `Workspace

titan.Parent = game.Workspace

6 comments

0

it gave no errors which is good but it doesnt teleport

0

Did you try titan.Head.Position = Vector3.new ()

0

yes

0

Try a CFrame

0

You have to parent it to Workspace. Added a line in my answer.

0

The titan defined on line 1 is created with a call to ;Clone(), meaning it has no parent and won't show up anywhere unless you make its parent somwhere in the workspace

HumanoidRootPart is an Instance

Not a Vector3

That's it. Just use the Position.

You're refering the Head itself, not the position. So It would be:

titan.Head.Position = game.Workspace:FindFirstChild(player.name).HumanoidRootPart.Position

In case It doesn't work, set the CFrame instead:

titan.Head.CFrame = game.Workspace:FindFirstChild(player.name).HumanoidRootPart.CFrame

5 comments

0

that was line 6 not line 7

0

that was line 6 not line 7

0

Opsie... Read my edit

0

it doesnt teleport the model in replicated storage

0

Maybe the issue is you didn't parent the titan clone to Workspace

The reason it didn't work was because you didn't use a position at the end of line 7 HumanoidRootPart is an instance Also You have to get the character Remember that you need to use a cframe

You can change the script to your preference but basically, it just teleport the player to 0,50,0 studs

target = CFrame.new(0, 50, 0) --could be near a brick or in a new area
for i, player in ipairs(game.Players:GetChildren()) do
   --Make sure the character exists and its HumanoidRootPart exists
   if player.Character and player.Character:FindFirstChild("HumanoidRootPart") then
       --add an offset of 5 for each character
      player.Character.HumanoidRootPart.CFrame = target + Vector3.new(0, i * 5, 0)
   end
end

If my answer helped make sure to accept it

This discussion is preserved as it was. New answers, comments, and votes are closed.