My script that is in starterplayerscripts and obviously is a local script :)
Code:
local Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Root = Character:WaitForChild("HumanoidRootPart")
local RightShoulder = Character:FindFirstChild("RightShoulder", true)
local YOffset = RightShoulder.C0.Y
local CFNew, CFAng = CFrame.new, CFrame.Angles
game:GetService("RunService").RenderStepped:Connect(function() --Root.CFrame:toObjectSpace(Camera.CFrame).lookVector
local CameraDirection = Mouse.Hit.LookVector
if RightShoulder then
RightShoulder.C0 = CFrame.new(1, YOffset, 0) * CFrame.Angles(0, -math.asin(CameraDirection.X), 0) * CFrame.Angles(math.asin(CameraDirection.Y), 0, 0)
end
end)
so on axis Z- everything works good
on axis Z+ the X axis is inverse
on axis X+ and X- everything is weird
(these are the axis of the classic baseplate)
idk why it does that
pls help me i tried alot but all in vain
local Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Character = Player.Character or Player.CharacterAdded:Wait()
local Root = Character:WaitForChild("HumanoidRootPart")
local RightShoulder = Character:FindFirstChild("RightShoulder", true)
local YOffset = RightShoulder.C0.Y
local CFNew, CFAng = CFrame.new, CFrame.Angles
game:GetService("RunService").RenderStepped:Connect(function() --Root.CFrame:toObjectSpace(Camera.CFrame).lookVector
local CameraDirection = Root.CFrame:toObjectSpace(Mouse.Hit).lookVector
if RightShoulder then
RightShoulder.C0 = CFrame.new(1, YOffset, 0) * CFrame.Angles(0, -math.asin(CameraDirection.X), 0) * CFrame.Angles(math.asin(CameraDirection.Y), 0, 0)
end
end)
I fixed it lol i just needed to use the Root.CFrame:toObjectSpace(Mouse.Hit).lookVector
Thanks for your help btw
local Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local ToolEquipped = false
local Character = Player.Character or Player.CharacterAdded:Wait()
local Root = Character:WaitForChild("HumanoidRootPart")
local RightShoulder = Character:FindFirstChild("RightShoulder", true)
local Neck = Character:FindFirstChild("Neck", true)
local YOffset = RightShoulder.C0.Y
local YOffset3 = Neck.C0.Y
local Tool = nil
Character.ChildAdded:Connect(function(Child)
if Child:IsA("Tool") then
ToolEquipped = true
Tool = Child
end
end)
Character.ChildRemoved:Connect(function(Child)
if Child == Tool then
Tool = nil
ToolEquipped = false
end
end)
game:GetService("RunService").RenderStepped:Connect(function()
local CameraDirection = Root.CFrame:toObjectSpace(Mouse.Hit).lookVector
if RightShoulder then
local Offset = CFrame.Angles(math.rad(90), 0, 0)
if ToolEquipped == true then
Offset = CFrame.Angles(math.rad(0), 0, 0)
else
Offset = CFrame.Angles(math.rad(90), 0, 0)
end
Neck.C0 = CFrame.new(0, YOffset3, 0) * CFrame.Angles(0, -math.asin(CameraDirection.X), 0) * CFrame.Angles(math.asin(CameraDirection.Y), 0, 0)
RightShoulder.C0 = CFrame.new(1, YOffset, 0) * CFrame.Angles(0, -math.asin(CameraDirection.X), 0) * CFrame.Angles(math.asin(CameraDirection.Y), 0, 0) * Offset
end
end)