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

How do I compare a part's orientation?

I have a snippet of code below:

local weld = Instance.new("WeldConstraint")
if game.Workspace:WaitForChild("kindacoolguy4000").HumanoidRootPart.Orientation >= Vector3.new(0,0,0)then
	script.Parent.Position = game.Workspace:WaitForChild("kindacoolguy4000").HumanoidRootPart.Position + Vector3.new(0,1,5)
else
	script.Parent.Position = game.Workspace:WaitForChild("kindacoolguy4000").HumanoidRootPart.Position + Vector3.new(0,1,-5)
end
script.Parent.Orientation = game.Workspace:WaitForChild("kindacoolguy4000").HumanoidRootPart.Orientation
weld.Part0 = script.Parent
weld.Part1 = game.Workspace:WaitForChild("kindacoolguy4000").HumanoidRootPart
weld.Parent = game.Workspace:WaitForChild("kindacoolguy4000").HumanoidRootPart

and when I run the game I get the following error:

19:46:26.316 - Workspace.Birb.PetPart.Script:2: attempt to compare userdata 19:46:26.317 - Stack Begin 19:46:26.317 - Script 'Workspace.Birb.PetPart.Script', Line 2 19:46:26.318 - Stack End

I am unsure of how I am comparing userdata when both are vector3s (unless they aren't) can anyone explain this please?

1 answer

You're trying to weld the pet to the character right?

You can use cframe instead:

local humanoidRootPart = game.Workspace:WaitForChild("kindacoolguy4000").HumanoidRootPart
script.Parent.CFrame = humanoidRootPart.CFrame * CFrame.new(0,1, 5)

this will move the pet part 5 studs behind the humanoid root part and 1 stud above the humanoid root part relative to the players orientation.

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