Server Side character to mouse pivoting causing issues

Hello,

I am currently working on a gun system similar to the game Guts and Blackpowder. To start off, I decided to make the character pivoting to the mouse. However, I have ran into a major issue. I am trying to replicate the character to mouse pivoting on the server side rather than the client so all players could see it, however, I have ran into an issue in the attached video; the rotation works, but the player is stuck in place and can’t move. Is it possible to replicate this movement to the server, or should I stick to the client? I looked at other posts and adapted the code to the server but it simply will not work.

Local Script inside a tool:

local rep = game:GetService("ReplicatedStorage")
local rs = game:GetService("RunService")
local tool = script.Parent
local plr = game.Players.LocalPlayer
local char = plr.Character
local mouse = plr:GetMouse()
local events = tool.Events

tool.Equipped:Connect(function()
	mouse.Icon = rep.Assets.dot.Texture
	rs:BindToRenderStep("turn", 1, function()
		events.Turn:FireServer(mouse.Hit.Position)
	end)
end)

tool.Unequipped:Connect(function()
	mouse.Icon = ""
	rs:UnbindFromRenderStep("turn")
end)

Server script in the tool:

local tool = script.Parent
local plr = script.Parent.Parent.Parent
local char = plr.Character
local root = char.HumanoidRootPart
local Mouse = plr:GetMouse()
local rs = game:GetService("RunService")
local ts = game:GetService("TweenService")
local events = tool.Events

events.Turn.OnServerEvent:Connect(function(plr , mouse)
	local RootPos = root.Position
	ts:Create(root, TweenInfo.new(0.1, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut), {CFrame = CFrame.new(RootPos, Vector3.new(mouse.X, RootPos.Y, mouse.Z))}):Play()
end)

Thanks.

1 Like

I’ve had a similar issue also. Does anyone have any idea on how to solve this?

you don’t need a remote for this, it can all be done on the client

Will doing it on the client show it for the other players?

yeah it should, you can do a 2 player test to verify

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.