alright so this one is a bit different so ill explain the situation first, so if the player kills an enemy it ragdolls and if they get close to it a gui will appear on their screen but this issue occurs if there are 2 or more dead enemies within the "searchable radius" of them and i know why it happens i just cant think of a way to fix it, it happens because the script is relying on the player to be close to show the gui and far to delete it but i have it where it cant show the gui if it already exists in the players PlayerGui which i did on purpose but as i said too many at a time will just result in a spasm party of gui's
the issue is within the while loop line 23 to 38
Script:
local Players = game:GetService("Players")
local Object = script.Parent
local Human = script.Parent:WaitForChild("Humanoid")
Human.Died:Connect(function()
if script.Parent:FindFirstChild("Loot") == nil then
local LootEvent = script.Loot:Clone()
LootEvent.Parent = script.Parent
local LootScript = script.LootScript:Clone()
LootScript.Parent = script.Parent
LootScript.Disabled = false
local Drag = Instance.new("StringValue")
Drag.Name = "DraggableItem"
Drag.Parent = script.Parent
script.Parent.Nametag:Destroy()
end
end)
while true do
if Human.Health <= 0 then
for i,v in pairs(Players:GetChildren()) do
local mag = (Object.UpperTorso.Position - v.Character.UpperTorso.Position).magnitude
if mag <= 5 then
if v.PlayerGui:FindFirstChild("BindingOfKeys - Loot") == nil then
local Clone = script.Parent["BindingOfKeys - Loot"]:Clone()
Clone.ImageButton.PlayerControl.Disabled = false
Clone.Parent = v.PlayerGui
end
else
if mag <= 7 then
if v.PlayerGui:FindFirstChild("BindingOfKeys - Loot") then
v.PlayerGui:FindFirstChild("BindingOfKeys - Loot"):Destroy()
if mag <= 6 and v.PlayerGui:FindFirstChild("LootBag") then
v.PlayerGui.LootBag:Destroy()
end
end
end
end
end
end
wait(0.02)
end
