Search
 
SCRIPT & CODE EXAMPLE
 

LUA

roblox rotate head with camera

--Lua/Roblox
--Put this in starterplayerscripts as a localscript

local CFNew, CFAng = CFrame.new, CFrame.Angles
local asin = math.asin

local Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
repeat wait() until Player.Character
local Character = Player.Character
local Root = Character:WaitForChild("HumanoidRootPart")
local Neck = Character:FindFirstChild("Neck", true)
local YOffset = Neck.C0.Y
game:GetService("RunService").RenderStepped:Connect(function()
    local CameraDirection = Root.CFrame:toObjectSpace(Camera.CFrame).lookVector.unit
    if Neck then
        Neck.C0 = CFNew(0, YOffset, 0) * CFAng(0, -asin(CameraDirection.x), 0) * CFAng(asin(CameraDirection.y), 0, 0)
    end
end)
Comment

PREVIOUS NEXT
Code Example
Lua :: Set core GUI Roblox 
Lua :: roblox get how many players in server 
Lua :: roblox add attribute 
Lua :: lua input 
Lua :: subsgtitute string R 
Lua :: fivem lua set player bucket 
Lua :: fivem get closest player 
Lua :: lua math.random 
Lua :: C++ 914 card 
Lua :: table.move lua 
Lua :: lua table of alphabet 
Matlab :: matlab symbolic derivative 
Matlab :: octave mark axis labels 
Matlab :: how to get the highest power of polynomial matlab 
Matlab :: sin in scilab 
Basic :: cmd cant change directory 
Basic :: ogg to mp3 
Basic :: shortcut to rename the file on lenovo s340 
Elixir :: elixir fibonacci 
Elixir :: liveview component 
Scala :: scala function 
Scala :: scala list addall 
Actionscript :: dig WWW.EXAMPLE.COM +nostats +nocomments +nocmd 
Excel :: excel or 
Perl :: perl mongodb conf location 
Pascal :: pascal try catch finally 
Powershell :: how to download git on windows using power shell 
Clojure :: ex: Clojure define expected time 
Assembly :: pyplot name axes 
Assembly :: import svg in google slides 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =