So I need to set the network owner to the player when the ball hits the glass. I tried to use a script that unanchors everything and sets the network owner, but now it’s delayed.
Local Script:
script.Parent.SetNetworkOwner:FireServer()
Script:
local model = script.Parent
local Parts = model:WaitForChild("Parts")
local function setNetworkOwner(owner)
for i,v in ipairs(Parts:GetDescendants()) do
if v:IsA("BasePart") and v.Anchored == false then
v:SetNetworkOwner(owner)
end
end
end
local function unanchorAll()
for i,v in ipairs(Parts:GetDescendants()) do
if v:IsA("BasePart") then
v.Anchored = false
end
end
end
local function anchorAll()
for i,v in ipairs(Parts:GetDescendants()) do
if v:IsA("BasePart") then
v.Anchored = true
end
end
end
script.SetNetworkOwner.OnServerEvent:Connect(function(player)
unanchorAll()
setNetworkOwner(player)
anchorAll()
end)
It’s delayed because the code is structed in a very poor preforming way. The delay is from server to client communication. The glass freezing in mid air is because you tell the server to anchor those parts.
You’ve moved the all the code to the client? I don’t think that should be happening if it is. Is it possible if you can show me the code you have right now(The code that you moved to the client)?