All day I have been trying to fix this script, yet no success. My goal is to have the script detect an object within a Player's character and then act accordingly to said character being killed. The main issue seems to be detecting the object within the character. There are probably multiple reasons to why this script is not working, but I am not skilled enough yet to know what they may be.
The code:
dft = {} function GetPlayers() local c = game.Players:GetPlayers() for i = 1, #c do table.insert(dft, c[i].Name) end end local EnemyGUI = game.StarterGui:FindFirstChild("Enemy") local Draw = game.StarterGui:FindFirstChild("All Losers") function PresidentDeath() local thing = game.Players:FindFirstChild(dft["Character"]).President local president = thing.Parent president.Humanoid.Died:connect(function() local Humanoid = president:WaitForChild("Humanoid") if president.Humanoid:FindFirstChild("creator") ~= nil then -- If Humanoid was killed by another Player local Killer = Humanoid.creator.Value if Killer.TeamColor ~= president.Player.TeamColor or president.Humanoid.Health == 0 then for i,v in pairs(game.Players:GetPlayers()) do v.PlayerGui.Enemy.Frame.Visible = true print("worked once") end end end end) end while true do wait(3) PresidentDeath() end
You could use something called
GetDescendants()
Heres how you could learn how to use it:
https://wiki.roblox.com/index.php?title=API:Class/Instance/GetDescendants