I want to make this script serverside because it only shows up on clientside.
My issue is mainly my lack of knowledge of making something clientsided into serverside.
I tried just making it a script instead of localscript but surprise, surprise, that didn’t work. (I wish I were joking)
I also tried searching the forums, but I couldn’t find any explanation that made sense to me.
It’s a character lean/tilt script that tilts the player based on the direction the player is moving and locates inside PlayerGui.
local CFNew, CFAng = CFrame.new, CFrame.Angles
local rs = game:GetService("RunService")
local playerService = game:GetService("Players")
local headHorFactor = 1
local headVerFactor = .6
local bodyHorFactor = .5
local bodyVerFactor = .4
local plr = playerService.LocalPlayer
local c = plr.Character or plr.CharacterAdded:wait()
local hum = c:WaitForChild("Humanoid")
local r6 = hum.RigType == Enum.HumanoidRigType.R6
local h = c.Head
local r = c.HumanoidRootPart
local t = r6 and c.Torso or c.UpperTorso
local n = r6 and t.Neck or h.Neck
local w = not r6 and t.Waist
local neckC0 = n.C0
local waistC0 = not r6 and w.C0
local RootJoint = r.RootJoint
local LeftHipJoint = t["Left Hip"]
local RightHipJoint = t["Right Hip"]
local function Lerp(a, b, c)
return a + (b - a) * c
end
local Force = nil
local Direction = nil
local Value1 = 0
local Value2 = 0
local RootJointC0 = RootJoint.C0
local LeftHipJointC0 = LeftHipJoint.C0
local RightHipJointC0 = RightHipJoint.C0
rs.RenderStepped:Connect(function()
Force = r.Velocity * Vector3.new(1,0,1)
if Force.Magnitude > 2 then
Direction = Force.Unit
Value1 = r.CFrame.RightVector:Dot(Direction)
Value2 = r.CFrame.LookVector:Dot(Direction)
else
Value1 = 0
Value2 = 0
end
RootJoint.C0 = RootJoint.C0:Lerp(RootJointC0 * CFrame.Angles(math.rad(Value2 * 10), math.rad(-Value1 * 10), 0), 0.2)
LeftHipJoint.C0 = LeftHipJoint.C0:Lerp(LeftHipJointC0 * CFrame.Angles(math.rad(-Value1 * 10), 0, 0), 0.2)
RightHipJoint.C0 = RightHipJoint.C0:Lerp(RightHipJointC0 * CFrame.Angles(math.rad(Value1 * 10), 0, 0), 0.2)
end)