I’m not sure how i’m supposed to do it, help is appreciated
local source = script.Parent
local targettolookat = game.Workspace.ScriptedArtillery.EndPointer
while wait() do
source.CFrame = CFrame.new(source.Position, Vector3.new(targettolookat.Position.x, source.Position.y, targettolookat.Position.z))
end```
It’s not i think the issue is that endpointer is inside the scripted artillery, meaning that the model entire model can’t rotate to something that is inside it
local source = script.Parent
local targetToLookAt = game.Workspace.ScriptedArtillery.EndPointer
while wait() do
local sourcePosition = source.Position
local targetPosition = targetToLookAt.Position
local lookAtCFrame = CFrame.new(
Vector3.new(sourcePosition.x, sourcePosition.y, sourcePosition.z),
Vector3.new(targetPosition.x, sourcePosition.y, targetPosition.z)
)
source.CFrame = lookAtCFrame
end
This code calculates the lookAtCFrame by specifying the X and Z coordinates from the source and target positions, while maintaining the Y coordinate from the source position.
What exactly is “EndPointer”? If it’s a Part. then EndPointer.Position is a world space position. If it’s an Attachment, then EndPointer.Position is relative to its Parent Part, and EndPointer.WorldPosition would be where it actually is in the world.
Obviously, in either case, if EndPointer gets moved when you change source.CFrame, then you have a positive feedback loop and the whole thing’s gonna chase its own tail.
EndPointer is a part in his code due to its property name. Also what he is doing is looping forever as he use a while loop and not EndPointer:GetPropertyChangedSignal("Position) .
GetPropertyChangedSignal does not fire for certain properties like Position, much like how Changed behaves. At least this was the behavior I’ve observed years back.
Even if so, it does not have any performance benefit over RunService.