Skip to content

Commit

Permalink
Fix bug: Player can take network ownership of NPC characters (#331)
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Toney authored Jan 6, 2025
1 parent 8c696cf commit 646b854
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 3 deletions.
22 changes: 21 additions & 1 deletion src/ServerScriptService/MatchManagementScript.server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,35 @@ local function startRound()
local character = ServerStorage.NPCRigs.Rig:Clone();
character.Name = contestant.name;
character.Parent = workspace;

local function resetNetworkOwnership(instance: Instance)

if instance:IsA("BasePart") then

while not instance:CanSetNetworkOwnership() do

task.wait();

end;

instance:SetNetworkOwner();

end;

end;

character.DescendantAdded:Connect(resetNetworkOwnership);

for _, part in ipairs(character:GetDescendants()) do

if part:IsA("BasePart") then

part:SetNetworkOwner(nil);
part:SetNetworkOwner();

end;

end;

contestant:updateCharacter(character);

end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ function ExplosiveMimicServerArchetype.new(): ServerArchetype

if part:IsA("BasePart") then

part:SetNetworkOwner(nil);
part:SetNetworkOwner();

end;

Expand Down
2 changes: 1 addition & 1 deletion src/ServerStorage/Modules/createRagdollClone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ return function(character: Model): Model

if part:IsA("BasePart") and part.Name ~= "HumanoidRootPart" then

part:SetNetworkOwner(nil)
part:SetNetworkOwner()

end

Expand Down

0 comments on commit 646b854

Please sign in to comment.