Hi there, I’m making a rotating system for my web swinging
This is what it looks like https://gyazo.com/93896085860dbf156884f9d1e0045738
This is the problem I’m currently trying to solve https://gyazo.com/271540e555b17663ff2082b7442bf138
As you can see, the player can only face 1 single direction, I want to make them be able to rotate with WASD while keeping this feature.
Heres the code for it
game.Players.PlayerAdded:Connect(function(plr)
local hrp = plr.CharacterAdded:Wait().HumanoidRootPart
local hrpCF = hrp.CFrame
local gyro = Instance.new("BodyGyro", hrp)
local part2 = workspace.part2
gyro.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
gyro.P = 20000
local front = hrp.CFrame.LookVector
local up = hrp.CFrame.RightVector
game["Run Service"].Stepped:Connect(function()
local dist = (part2.CFrame:ToObjectSpace(hrp.CFrame)).Position.Unit
local angleX = 90 - math.deg(math.acos((dist:Dot(front))))
local angleZ = 90 - math.deg(math.acos((dist:Dot(up))))
gyro.CFrame = CFrame.new(hrp.CFrame.p) * CFrame.Angles(math.rad(angleX), 0, math.rad(angleZ))
end)
end)