So I want to know how I can set the ownership to all players.
Client:
script.Parent.SetNetworkOwner:FireServer()
Server:
local model = script.Parent
local function setNetworkOwner(model, owner)
for i,v in ipairs(model:GetDescendants()) do
if v:IsA("BasePart") then
local success, errorReason = v:CanSetNetworkOwnership()
if success then
v:SetNetworkOwner(owner)
end
end
end
end
script.SetNetworkOwner.OnServerEvent:Connect(function(player)
setNetworkOwner(model, player)
end)
But the problem is that if a player joins, the whole model only works for the player that joins.
Well, the client script only works for the local player and so if a player joins, that client script would run and fire the remote event so the server can set it to that player.
Then you have to think about structuring it differently. Set the network ownership based on who’s closest to the part, or have the clientscript just work entirely differently. You could also use tags and have a localscript running from all players that then gets the model through the tag.
It’s hard for me to say what the best or easiest way would be, when I don’t know what the localscript or the model entails, or why you’ve made it work the way it does in the first place.
It wont work because model is the player you need to set the ownership too and owner would be the model im pretty sure. I dont really use the second parameter that often too know what it is but im pretty sure its an empty variable.
That is incorrect. It can be set locally by all players.
Edit: what I meant by locally was have the object that you want set to all players is have the part anywhere other than workspace and then have a local script move the location of the part into the workspace.