How to make your Character Head follow your cursor in Roblox studio
HTML-код
- Опубликовано: 22 авг 2024
- Follow me in Roblox! please.?
0winto100win
scripts
local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Angles = CFrame.Angles
local aSin = math.asin
local aTan = math.atan
local MseGuide = true
local TurnCharacterToMouse = false
local HeadHorFactor = 1
local HeadVertFactor = 0.6
local CharacterHorFactor = 0.5
local CharacterVertFactor = 0.4
local UpdateSpeed = 0.5
if TurnCharacterToMouse == true then
MseGuide = true
HeadHorFactor = 0
CharacterHorFactor = 0
end
Player.CharacterAdded:Connect(function(char)
local Character = char
local Head = Character:WaitForChild("Head")
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local IsR6 = (Humanoid.RigType.Value==0)
local Torso = (IsR6 and Character:WaitForChild("Torso")) or Character:WaitForChild("UpperTorso")
local Neck = (IsR6 and Torso:WaitForChild("Neck")) or Head:WaitForChild("Neck")
local Waist = (not IsR6 and Torso:WaitForChild("Waist"))
local NeckOrgnC0 = Neck.C0
local WaistOrgnC0 = (not IsR6 and Waist.C0)
Neck.MaxVelocity = 1/3
game:GetService("RunService").RenderStepped:Connect(function()
local CameraCF = Camera.CoordinateFrame
if ((IsR6 and Character["Torso"]) or Character["UpperTorso"])~=nil and Character["Head"]~=nil then
local TorsoLV = Torso.CFrame.lookVector
local HdPos = Head.CFrame.p
if IsR6 and Neck or Neck and Waist then
if Camera.CameraSubject:IsDescendantOf(Character) or Camera.CameraSubject:IsDescendantOf(Player) then
local Dist = nil;
local Diff = nil;
if not MseGuide then
Dist = (Head.CFrame.p-CameraCF.p).magnitude
Diff = Head.CFrame.Y-CameraCF.Y
if not IsR6 then
Neck.C0 = Neck.C0:lerp(NeckOrgnC0*Angles((aSin(Diff/Dist)*HeadVertFactor), -(((HdPos-CameraCF.p).Unit):Cross(TorsoLV)).Y*HeadHorFactor, 0), UpdateSpeed/2)
Waist.C0 = Waist.C0:lerp(WaistOrgnC0*Angles((aSin(Diff/Dist)*CharacterVertFactor), -(((HdPos-CameraCF.p).Unit):Cross(TorsoLV)).Y*CharacterHorFactor, 0), UpdateSpeed/2)
else
Neck.C0 = Neck.C0:lerp(NeckOrgnC0*Angles(-(aSin(Diff/Dist)*HeadVertFactor), 0, -(((HdPos-CameraCF.p).Unit):Cross(TorsoLV)).Y*HeadHorFactor),UpdateSpeed/2)
end
else
local Point = Mouse.Hit.p
Dist = (Head.CFrame.p-Point).magnitude
Diff = Head.CFrame.Y-Point.Y
if not IsR6 then
Neck.C0 = Neck.C0:lerp(NeckOrgnC0*Angles(-(aTan(Diff/Dist)*HeadVertFactor), (((HdPos-Point).Unit):Cross(TorsoLV)).Y*HeadHorFactor, 0), UpdateSpeed/2)
Waist.C0 = Waist.C0:lerp(WaistOrgnC0*Angles(-(aTan(Diff/Dist)*CharacterVertFactor), (((HdPos-Point).Unit):Cross(TorsoLV)).Y*CharacterHorFactor, 0), UpdateSpeed/2)
else
Neck.C0 = Neck.C0:lerp(NeckOrgnC0*Angles((aTan(Diff/Dist)*HeadVertFactor), 0, (((HdPos-Point).Unit):Cross(TorsoLV)).Y*HeadHorFactor), UpdateSpeed/2)
end
end
end
end
end
if TurnCharacterToMouse == true then
Humanoid.AutoRotate = false
HumanoidRootPart.CFrame = HumanoidRootPart.CFrame:lerp(CFrame.new(HumanoidRootPart.Position, Vector3.new(Mouse.Hit.p.x, HumanoidRootPart.Position.Y, Mouse.Hit.p.z)), UpdateSpeed / 2)
else
Humanoid.AutoRotate = true
end
end)
end)
Yw!!
-Scripts-
local Camera = game.Workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Angles = CFrame.Angles
local aSin = math.asin
local aTan = math.atan
local MseGuide = true
local TurnCharacterToMouse = false
local HeadHorFactor = 1
local HeadVertFactor = 0.6
local CharacterHorFactor = 0.5
local CharacterVertFactor = 0.4
local UpdateSpeed = 0.5
if TurnCharacterToMouse == true then
MseGuide = true
HeadHorFactor = 0
CharacterHorFactor = 0
end
Player.CharacterAdded:Connect(function(char)
local Character = char
local Head = Character:WaitForChild("Head")
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart = Character:WaitForChild("HumanoidRootPart")
local IsR6 = (Humanoid.RigType.Value==0)
local Torso = (IsR6 and Character:WaitForChild("Torso")) or Character:WaitForChild("UpperTorso")
local Neck = (IsR6 and Torso:WaitForChild("Neck")) or Head:WaitForChild("Neck")
local Waist = (not IsR6 and Torso:WaitForChild("Waist"))
local NeckOrgnC0 = Neck.C0
local WaistOrgnC0 = (not IsR6 and Waist.C0)
Neck.MaxVelocity = 1/3
game:GetService("RunService").RenderStepped:Connect(function()
local CameraCF = Camera.CoordinateFrame
if ((IsR6 and Character["Torso"]) or Character["UpperTorso"])~=nil and Character["Head"]~=nil then
local TorsoLV = Torso.CFrame.lookVector
local HdPos = Head.CFrame.p
if IsR6 and Neck or Neck and Waist then
if Camera.CameraSubject:IsDescendantOf(Character) or Camera.CameraSubject:IsDescendantOf(Player) then
local Dist = nil;
local Diff = nil;
if not MseGuide then
Dist = (Head.CFrame.p-CameraCF.p).magnitude
Diff = Head.CFrame.Y-CameraCF.Y
if not IsR6 then
Neck.C0 = Neck.C0:lerp(NeckOrgnC0*Angles((aSin(Diff/Dist)*HeadVertFactor), -(((HdPos-CameraCF.p).Unit):Cross(TorsoLV)).Y*HeadHorFactor, 0), UpdateSpeed/2)
Waist.C0 = Waist.C0:lerp(WaistOrgnC0*Angles((aSin(Diff/Dist)*CharacterVertFactor), -(((HdPos-CameraCF.p).Unit):Cross(TorsoLV)).Y*CharacterHorFactor, 0), UpdateSpeed/2)
else
Neck.C0 = Neck.C0:lerp(NeckOrgnC0*Angles(-(aSin(Diff/Dist)*HeadVertFactor), 0, -(((HdPos-CameraCF.p).Unit):Cross(TorsoLV)).Y*HeadHorFactor),UpdateSpeed/2)
end
else
local Point = Mouse.Hit.p
Dist = (Head.CFrame.p-Point).magnitude
Diff = Head.CFrame.Y-Point.Y
if not IsR6 then
Neck.C0 = Neck.C0:lerp(NeckOrgnC0*Angles(-(aTan(Diff/Dist)*HeadVertFactor), (((HdPos-Point).Unit):Cross(TorsoLV)).Y*HeadHorFactor, 0), UpdateSpeed/2)
Waist.C0 = Waist.C0:lerp(WaistOrgnC0*Angles(-(aTan(Diff/Dist)*CharacterVertFactor), (((HdPos-Point).Unit):Cross(TorsoLV)).Y*CharacterHorFactor, 0), UpdateSpeed/2)
else
Neck.C0 = Neck.C0:lerp(NeckOrgnC0*Angles((aTan(Diff/Dist)*HeadVertFactor), 0, (((HdPos-Point).Unit):Cross(TorsoLV)).Y*HeadHorFactor), UpdateSpeed/2)
end
end
end
end
end
if TurnCharacterToMouse == true then
Humanoid.AutoRotate = false
HumanoidRootPart.CFrame = HumanoidRootPart.CFrame:lerp(CFrame.new(HumanoidRootPart.Position, Vector3.new(Mouse.Hit.p.x, HumanoidRootPart.Position.Y, Mouse.Hit.p.z)), UpdateSpeed / 2)
else
Humanoid.AutoRotate = true
end
end)
end)
How do u make the full body to follow the cursor like combat iniation and some other games
@@margooblutr5161 i didnt rlly got you mind showin a vid of it?
@@exoxrs i dont know how to make videos but try looking at combat initiation videos and look how their character follows the cursor like the full body in r6
@@margooblutr5161 alr imma try to make it asap!
@@exoxrs its alr take ur time