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

Having part rotate to point towards Vector3 position?

Asked by 6 years ago
Edited 6 years ago

I tried with BodyGyros and BodyPositions, but I just cant get it to work.

I need it to point towards a Vector3 / CFrame position constantly

EDIT: Code

local player = game.Players.LocalPlayer
repeat wait() until player
local mouse = player:GetMouse()
local character = workspace.stick
local root = character:WaitForChild("cent")
local rootgyro = Instance.new("BodyGyro",root)
rootgyro.P = 500
local factor = 4
round = function(num)
    return math.floor((num + factor / 2) / factor) * factor -- Here is the function I would like to change
end
local originCF = character.PrimaryPart.CFrame
while wait() do
    local h = mouse.Hit
    character:SetPrimaryPartCFrame(originCF * CFrame.fromEulerAnglesXYZ(round(h.X), 0, round(h.Z)))
end
0
Can you give us your code? MakeYourEscape 334 — 6y
0
Sure SebbyTheGODKid 198 — 6y
0
Have you tried this; CFrame.new(Vector3 Position, Vector3 LookAt) which will make the CFrame look at the 2nd Vector3 argument. UgOsMiLy 1074 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

LocalScript:

local player = game:GetService("Players").LocalPlayer
local mouse = player:GetMouse()
local character = workspace.stick

while wait() do
    character:SetPrimaryPartCFrame(CFrame.new(character.PrimaryPart.Position, mouse.Hit.p))
end

Note: Not for FE games.

Ad

Answer this question