Be able to rotate player while maintaining this feature

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)

First of all, if this is a server script, switch it to the client. You’ll cause lots of probable lag because of that RunService function.

Second of all, you could use UserInputService and once they press A just rotate them? Shouldn’t be too hard :stuck_out_tongue:

1 Like

Hi, thanks for your reply, I have switched to a local script as you have said, and added a UIS in order to rotate them 90 degrees on the Y axis. It doesn’t seem to have any effect though, it rotated the player briefly then snapped right back into the state they were before. I think the main problem is my code itself, but I’m pretty confused as to why the CFrame of my code is still the same when the player is rotated, even with the look vector and right vector