I want the character to face the mouse on all axis
for a bit of context I am making an ability that makes the player float in air and fires a bunch of bullets.
2, the bullet creating script in server, and character rotating script is client, so the server doesn’t know the character is rotating, but i want the bullets to spawn in front of the character humanoidrootpart
3.i did see this post Problem with torso following mouse server-sided
and i did not know what the only answer was talking about, i know what setnetworkownership is but does not help
RS.RenderStepped:Connect(function()
if LookAtMouse then
local MousePosition = mouse.Hit.Position
Character.HumanoidRootPart.CFrame = CFrame.new(Character.HumanoidRootPart.Position,Vector3.new(MousePosition.X, MousePosition.Y, MousePosition.Z))
end
end)
local Char = (reference your character here)
local MousePosition = (can be reference by Player:GetMouse().Hit.Position in a local script)
while task.wait() do
if (ability is enabled) then
Char:SetPrimaryPartCFrame(CFrame.lookAt(Char.PrimaryPart.Position, MousePosition))
end
end
Let me know if this works. You can use the CFrame.lookAt property to make a part face another position.
RS.RenderStepped:Connect(function()
if LookAtMouse then
local MousePosition = mouse.Hit.Position
Character.HumanoidRootPart.CFrame = CFrame.lookAt(Character.HumanoidRootPart.Position, MousePosition)
end
end)
That’s what I did, in the server, like i said in the post the rotating script is a local script, so the server does not know when it is rotating, so other players cannot see my humanoidrootpart rotating neither
Hmm. Try using remote events. Remote events can only be fired 20 times a second, however. You’re in a tricky situation.
Off the top of my head, I think the easiest way to solve your issue would be to have 4 remote events, and cycle through each one.
Fire the first one, task.wait(0.05), Fire the second remote event, task.wait(0.05), Fire the third remote event, etc. The more remote events you use, the less choppy the updating should look.
I’m going to make a post about this, because this is something that I want to know at some point, if it’s not the most efficient way.
Edit 2:
For whatever reason, it says online that a remote event can only be fired 20 times a second (which is not true), so you would only need 1 remote event.
(If you see this, please send a reply. Devforum doesn’t allow me to send more than 3 replies in a row)
local function ToggleLock()
local CameraController = cameras.activeCameraController
local MouseLockController = cameras.activeMouseLockController
CenterLocked = not CenterLocked
if CenterLocked then
if MouseLockController:GetIsMouseLocked() then -- toggle shift lock off
MouseLockController:OnMouseLockToggled()
end
CameraController:SetMouseLockOffset(Vector3.new())
CameraController:SetIsMouseLocked(true)
BoundKeys.Value = "" -- disables shift lock toggle
else
CameraController:SetIsMouseLocked(false)
BoundKeys.Value = OldBoundKeys -- restores shift lock toggle
end
end
@Smartmunkee please read this post. The issue is that the player is only being rotated on their screen, since it’s in a local script. And the bullets are not spawning at the same place as the player.