Why won't this script work?

Hello there! I’m having issues making a script for my future game:

In the first script, I want a part to remain above my character head, which works as expected:

local Part  = workspace:WaitForChild("Part")
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Head : BasePart = Character:WaitForChild("Head")

while task.wait() do
	Part.Orientation = Head.Orientation
	Part.Position = Head.Position + Vector3.new(0, 4, 0)
end

However, when I try to use a Model’s PrimaryPart instead, it simply doesn’t move. I’m getting this error and I’m pretty lost since Orientation IS a property of PrimaryPart.

local Model  = workspace:WaitForChild("FBXImportGeneric")
local PrimaryPart : BasePart = Model.PrimaryPart

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Head : BasePart = Character:WaitForChild("Head")

while task.wait() do
	PrimaryPart.Orientation = Head.Orientation
	PrimaryPart.Position = Head.Position
end

Any help is appreciated! <3

1 Like

The model does have a PrimaryPart set.

Edit: the PrimaryPart had no collision, so it fell into the void when starting the game. I fixed it, and now I’m not getting erros anymore, but the model is still not moving.

Is your PrimaryPart anchored or not?

It isn’t. (Taking space ༼ つ ◕_◕ ༽つ)

Since you are using the PrimaryPart’s Orientation and Position, you could use Model:PivotTo(Head.CFrame)

2 Likes

Fixed my issue, thanks! (Taking space ༼ つ ◕_◕ ༽つ)

1 Like

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