SpiralAPI
(fortnitegodspiral)
March 18, 2021, 4:10pm
#1
I am trying to make a script that will constantly update a model (rigged with welds + a primarypart) to constantly look towards another part.
This is what I have gotten so far, and I want the camera to rotate towards the red part.
I have tried numerous other posts answers but couldn’t seem to get it working myself.
Above is an image of my hitbox, in case it helps.
1 Like
dandcx
(dandcx)
March 18, 2021, 4:12pm
#2
I’m pretty sure CFrame.lookAt()
will help
Which you can find here
https://developer.roblox.com/en-us/api-reference/datatype/CFrame
2 Likes
SpiralAPI
(fortnitegodspiral)
March 18, 2021, 4:17pm
#3
Do you have any examples of using this? I am still a bit confused on CFrames as a whole.
example
RunService.Heartbeat:Connect(function()
local cf = Model:GetPrimaryPartCFrame()
-- this gets the model's CFrame if it has a primary part (required)
Model:SetPrimaryPartCFrame(CFrame.lookAt(cf.Position, Target.Position))
-- this sets the cframe to look at the part
end)
https://developer.roblox.com/en-us/api-reference/class/Model
2 Likes
A CFrame
is the Position
and Orientation
of a part.
2 Likes
SpiralAPI
(fortnitegodspiral)
March 18, 2021, 4:26pm
#6
Hi! I understand it a bit more now, and this worked! Thank you so much!
1 Like