The code for CFrame rotational parts of the script don't work, how to fix it?!

An object, which is the parent is supposed to follow the player's humanoidrootpart position using CFrame.

The object is supposed to "look" welded to the player even though it's actually not



local LocalPlayer = game.Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:wait()

game:GetService('RunService').RenderStepped:Connect(function()

script.Parent.CFrame = CFrame.new(Character.HumanoidRootPart.Position) 
 CFrame.fromOrientation(0,Character.HumanoidRootPart.Orientation.y,0)
                       


end)

3 comments

0

What doesn't work? What does it do? What do you want it to do ?

0

LocalScript only works if it is a descendant of one of the following objects: A Player's Backpack, A Player's Character model, A Player's PlayerGui, A Player's PlayerScripts, The ReplicatedFirst service. Also, If the the LocalScript is a descendant of Workspace, then I suggest transferring/copying and pasting from line 4 to line 11, to a normal script.

0

@thesit123 A regular script wont work for what I'm trying to do. I'm CFraming the part to the player.