Recently I found can issue with my weapon system, the issue is that local viewmodel movement doesn’t replicate to server and to other user the fighting seems unrealistic. I’m trying to figure out how to replicate the client movement to the server one, I haven’t found any fix yet…
There’s not enough information for me to know exactly how you’re making the viewport follow the camera, but I’m guessing you manipulated the C0 joints of the character. In my game, when I needed to replicate head movement, I copied the C0 CFrames and sent them to the server. The server then passed them back down to the other clients.
Although the server doesn’t directly manipulate the joints, other clients will be able to see the movement. This approach requires using UnreliableEvent. While RemoteEvents can be used, I suggest UnreliableEvent because it can be less taxing on the server. Here’s an example of how the server script can look:
local characterValues = {}
local function onCharacterAdded(character)
character:WaitForChild("Humanoid")
local targetCFrame = Instance.new("CFrameValue", character)
targetCFrame.Name = "targetCFrame"
local headCFrame = Instance.new("CFrameValue", character)
headCFrame.Name = "headCFrame"
local armsCFrame = Instance.new("CFrameValue", character)
armsCFrame.Name = "armsCFrame"
characterValues[character] = {targetCFrame, headCFrame, armsCFrame}
character.Humanoid.Died:Connect(function()
characterValues[character] = nil
end)
end
local function onPlayerAdded(player)
player.CharacterAdded:Connect(onCharacterAdded)
end
-- So it works fine in Studio as well.
for _, player in pairs(game.Players:GetPlayers()) do
onPlayerAdded(player)
end
game.Players.PlayerAdded:Connect(onPlayerAdded)
UnreliableEvent.OnServerEvent:Connect(function(player, targetCFrame, headCFrame, armsCFrame)
if player.Character and characterValues[player.Character] then
characterValues[player.Character][1].Value = targetCFrame -- UpperTorso Cf
characterValues[player.Character][2].Value = headCFrame -- Head Cf
characterValues[player.Character][3].Value = armsCFrame -- Arms Cf
end
end)
I hope this helps you get closer to solving your issue. While my answer may not directly address your specific problem, I hope it provides enough information to give you a better understanding of what you can do and what is possible.