game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Wait()
while wait() do
script.Parent.CFrame.Y = CFrame.lookAt(script.Parent.Position, player.Character.PrimaryPart.Position)
end
end)
what is the error? It’d be helpful to know
Literally just the Line 4…
Script ‘Workspace.YLookAt.Script’, Line 4 - Studio - Script:4
I don’t think you’re allowed to set CFrame.Y, try doing
script.Parent.CFrame = CFrame.lookAt(script.Parent.Position, player.Character.PrimaryPart.Position)
Yes, but I want to only change the CframeY
Try this
script.Parent.CFrame = CFrame.lookAt(script.Parent.Position, Vector3.new(script.Parent.Position.X, player.Character.PrimaryPart.Position.Y, script.Parent.Position.Z))
It creates a lookat with the script.Parent’s position for the x and z values so those remain unchanged and only uses the primary parts Y position
It’s not moving at all, no errors
Well it moves, but not directly towards the player and faces straight down
if it helps here is what when I put it in a print it returns.
-5.07476807, 14, -4.16524315, 0, 1, -0, 0, -0, -1, -1, 0, -0
Is your part correctly aligned? Try putting a decal into the part temporarily and check which face is Front because the front is what’s going to be facing the player.
Which side of the part is supposed to face the player?
The front, I’m gonna make this into a artillery framework.
Y would be the barrel X would be the turret.
Changed it to this
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Wait()
while wait() do
script.Parent.CFrame = CFrame.lookAt(script.Parent.Position, Vector3.new(player.Character.PrimaryPart.Position.X, script.Parent.Position.X, script.Parent.Position.Z))
end
end)
still a bit too low
EDIT: my copy paste broke and this doesn’t work pls ignore everything I said here because it was all messed up and wrong. I deleted this so noone else accidentally tries to do this.
Remember to make sure the part is anchored too
Whats the orientation of your part?
-90, 0, 0 aaaaaaaaaaaaaaaaaaaaaaa
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Wait()
while wait() do
script.Parent.CFrame = CFrame.lookAt(script.Parent.Position, Vector3.new(script.Parent.Position.X, player.Character.PrimaryPart.Position.Y, script.Parent.Position.Z))
end
end)
EDIT: I copied wrong ignore my advice pls