Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a way to rotate a dummy to look directly at you?

Asked by 4 years ago

Let's say i wanted to rotate the dummy's entire body to look towards the player's HumanoidRootPart is there a way to rotate the dummy's HumanoidRootPart in a loop?

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

We can change the CFrame of the dummys HumanoidRootPart. There is a constructor of CFrame that lets us create a CFrame that is at position a and looks at position b. It is CFrame.new(Vector3 a, Vector3 b)

https://developer.roblox.com/en-us/api-reference/datatype/CFrame

local dummy = script.Parent
local dummyHRP = dummy.HumanoidRootPart

local lookAtPart = nil -- this is a BasePart that we would like to look at 

lookAtPart:GetPropertyChangedSignal("Position"):Connect(function()
    dummyHRP.CFrame = CFrame.new(dummyHRP.CFrame.Position, lookAtPart.Position)
end)
0
Does this work in a localscript if i modify the values correctly? FrankyLovesGames 35 — 4y
0
Yes, but the position of the dummy would not replicate to the server. EncapsuIation 450 — 4y
0
That's exactly what i'm going for, thanks! FrankyLovesGames 35 — 4y
0
Please mark my answer as correct if it helped you. EncapsuIation 450 — 4y
Ad

Answer this question