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

How can I change the rotation of this object to face the player?

Alright, so I've got a part with a SurfaceGui that's locally made and positioned right in front of the player (2 studs in front of him) but it's facing away from the player, not towards the player. So, the player can't see the GUI.

local c = script.GUI:Clone()
c.Parent = game.Workspace.CurrentCamera
c.SurfaceGui.TextLabel.Text = "CREATED!"
repeat
	c.CFrame = game.Players.LocalPlayer.Character.Head.CFrame + game.Players.LocalPlayer.Character.Head.CFrame.lookVector * 2
	wait()
until (1 == 5) -- 1 will never be equal to 5, so :p

How can I change the rotation of the brick to face towards the player?

Thanks! :)

1 answer

✓ Accepted answer
local run = game:GetService('RunService')
local player = game.Players.LocalPlayer
local char = player.Character
local head = char:WaitForChild("Head")

run.RenderStepped:connect(function()
	-- Start at your head
	-- Rotate around 180 degrees
	-- Push away from your head 
	c.CFrame = head.CFrame * CFrame.Angles(0,math.rad(180),0) +  (head.CFrame.lookVector *2) 
end)

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