My hockey puck’s physics become scuffed when multiple players play (specifically 1+ mobile player(s) and 1+ PC player(s)) (Only the mobile player’s interactions with the puck are scuffed) I’ve tried setting the puck’s Network Ownership to nil, but it makes both PC’s and Mobile’s physics scuffed, and I’ve also set it to a random player which fixes the physics for the random player but when any other players interact with the puck it is scuffed again. Also, by scuffed I mean laggy, slow, forces are weakened, and physics just don’t work as intended. The Puck also has custom physical properties and BodyForces that are added to it when players hit it.
So there is no error in the code but rather the code doesn’t fix the physics like I want it to. I want it to make the physics of the puck run smoothly for all players but it only makes it run smoothly for the player I assign network ownership to and makes it scuffed for the rest of the players:
game.ReplicatedStorage.Player1.Changed:Connect(function()
if script.Parent.Anchored == false then
script.Parent:SetNetworkOwner(game.ReplicatedStorage.Player1.Value) -- This is a player
end
end)
task.wait(0.545)
script.Parent:SetNetworkOwner(game.ReplicatedStorage.Player1.Value) -- This is a player
You really shouldn’t rely on Roblox physics for things like this, unfortunately. Your best bet for a case like this is to make a puck locally for every client, and tween the pucks position whenever it’s interacted with. A method like this will take a bit of fiddling with code and might have some quirks to functionality, but it’s definitely better than relying on Roblox physics.
Have to agree honestly. If you wanna mess with roblox physics, its complex but usually pays off. I’d recommend you look into making custom glide physics @VolcanicsDev because if you rely on roblox, stuff always goes sideways
set it to a random player which fixes the physics for the random player but when any other players interact with the puck it is scuffed again.
Set the network owner to the closest client in a ‘Stepped’ event loop.
local Game = game
local Players = Game:GetService("Players")
local RunService = Game:GetService("RunService")
local Puck = nil --Reference to the 'Puck' object.
local function OnStep()
local Closest = {Player = nil, Distance = math.huge} --Decrease 'math.huge' to reduce the range.
for _, Player in ipairs(Players:GetPlayers()) do
local Distance = Player:DistanceFromCharacter(Puck.Position)
if Distance == 0 or Distance > Closest.Distance then continue end
Closest.Distance = Distance
Closest.Player = Player
end
Puck:SetNetworkOwner(Closest.Player) --Set network owner to a client (or the server if no clients in range).
end
RunService.Stepped:Connect(OnStep)
Just realized why it wasn’t forcing when a player hits it for the first time after another player hits hit and it had nothing to do with the NetworkOwner so thank you all for all of your help! I think it works perfectly as intended now!