I am trying to make a couple of scripts where if someone with a certain role dies, every player in the server loses any weapons they might have. However, this only works in studio for some reason and doesn't work in the actual game. What is the problem?
Local Script:
player = game.Players.LocalPlayer
character = player.Character or player.CharacterAdded:Wait()
humanoid = character:WaitForChild("Humanoid")
nightguardGone = game.ReplicatedStorage.Remotes.NightguardGone
removeWeapons = game.ReplicatedStorage.Remotes.RemoveWeapons
humanoid.Died:Connect(function()
if player:WaitForChild("Info").Role.Value == "Nightguard" then
nightguardGone:FireServer()
removeWeapons:FireServer()
end
end)
Server Script:
removeWeapons = game.ReplicatedStorage.Remotes.RemoveWeapons
removeWeapons.OnServerEvent:Connect(function(player)
for _, plr in pairs(game.Players:GetPlayers()) do
for _, tool in pairs(plr.Backpack:GetChildren()) do
tool:Destroy()
end
end
print("Took Possible Weapon From Player")
end)
And to clarify, yes it does indeed print.

1 comment
i was thinking thar