Because you are setting the network ownership to each player and you keep updating it 60 times a second. I would suggest using network ownership but also do something else instead of updating it 60 times a second, like maybe lerping (Advanced Roblox Scripting Tutorial #12 - Lerp / Lerping (Beginner to Pro 2019) - YouTube) the object or tweening (TweenService | Roblox Creator Documentation) it.
Since if Network Ownership is set on a character, the character will appear to lag since inputs are sent to the server and the character movement is sent back to the client (which takes time to do).
Thank you so much! Iâll try these things out and see how they do. I knew I was missing something.
I checked and my characterâs arms already have network ownership set to my player. Arm movement is not seen by other players. I guess network ownership doesnât work? Or am I doing something wrong?
Could you show me a video and also is it on the server? The network ownership isnât to move stuff, its to give network ownership meaning to give âownership.â
I only move stuff on the client. To get arm movement to show to other players, I send the armâs new position to the server, then the server sends the position to every other player, and each player updates my characterâs arm position from a local script. I look up online and it says that properties of parts donât replicate with network ownership, so Iâll try using the TweenService instead. Iâll replicate arm positions maybe every 10th of a second and then use the TweenService to make the arm move smoothly instead of jumping to its new position.
Ok, I got it set up, but it still looks a bit laggy. Now, even player movement looks laggy on the server.
I give up. Roblox is supposed to be simple in theory, but thereâs so much behind-the-scenes stuff that makes it a huge pain to develop and debug code. Iâve wasted so much time trying to implement something that shouldnât even be hard to do on another game engine.
It would be nice to see a video of what you mean.
I could post a video, but Iâm not even sure if that will resolve the problem. Roblox is weird because sometimes player movement looks super smooth when I look at other players moving around, and other times it looks choppy like theyâre moving at 30 fps. It does this randomly even when I test the game. So glitchy and frustrating. Iâm an impatient person, and I guess game dev is not for me. Or maybe I need to switch to Unity or Unreal or something.
This is because the other players control their characters meaning there comes the problem of their internet being too laggy to look smooth.
Ok, sorry for being so discouraged. I messed around some more with my code and I found that sending the remote event every 10th of a second and then tweening in between events makes it look smooth. Iâm not sure why this wonât work when sending every 20th of a second and tweening in between events. Here is my code, btw.
-- LocalScript inside StarterCharacterScripts
local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
local sendRate = 1/10
remoteEvent.OnClientEvent:Connect(function(sender, transform)
spawn(function()
local tweenInfo = TweenInfo.new(sendRate, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut)
local goal = {Transform = transform}
local tween = TweenService:Create(sender.Character.Torso["Right Shoulder"], tweenInfo, goal)
tween:Play()
end)
end)
local localPlayer = Players.LocalPlayer
local mouse = localPlayer:GetMouse()
local character = script.Parent
local torso = character:WaitForChild("Torso")
local rightArm = character:WaitForChild("Right Arm")
local rightShoulder = torso:WaitForChild("Right Shoulder")
start = os.clock()
RunService.RenderStepped:Connect(function()
local angle = math.asin((mouse.Hit.Position - mouse.Origin.Position).Unit.Y)
if os.clock() - start >= sendRate then
remoteEvent:FireServer(CFrame.Angles(0, 0, angle) * CFrame.Angles(0, 0, math.deg(-90)))
start = os.clock()
end
end)
-- ServerScript inside ServerScriptService
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remoteEvent = ReplicatedStorage:WaitForChild("RemoteEvent")
remoteEvent.OnServerEvent:Connect(function(sender, transform)
for index, player in pairs(Players:GetChildren()) do
if player.Name == sender.name then
remoteEvent:FireClient(player, sender, transform)
end
end
end)
For testing purposes, Iâm making input only work through remote events lol. That way, I can test with only one player in the game. There is a bit of a delay when moving the mouse, but this makes it easier to test than opening a server and having 2 players in the game every time I change something and need to test my code.
It would definitely be similar or harder if you go for a server-client network architecture.
Yeah, this is a big pain, but at least I finally got it working! Sending remotes 10 times a second to pass the playerâs arm position seems to look the smoothest. Thereâs a bit of a delay, but when the arm moves, it looks good! Thank you all for the help!
Yay! Im happy that you finally got it working!
Good luck on your journey!