Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Having part rotate to point towards Vector3 position?

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

3 comments

0

Can you give us your code?

0

Sure

0

Have you tried this; CFrame.new(Vector3 Position, Vector3 LookAt) which will make the CFrame look at the 2nd Vector3 argument.

1 answer

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.