Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Find humanoid through a variable?

Asked by 10 years ago

Okay, I am trying to get a players humanoid through a variable. Currently, I have;

Okay, so I removed all of the locals and had no luck.

There was no output, and all my script is

game.ServerStorage["Give Items"].Event:connect(function()
players = {}
Assassin = ""
Protector = ""

function GetPlayers()
for i,v in pairs(game.Players:GetChildren()) do
table.insert(players,v)
end
end

GetPlayers()

function SelectPlayer()
num = math.random(1,#players)
Assassin = players[num].Name
print('Assassin is: ' ..Assassin)
end

SelectPlayer()

function SelectPlayer2()
num = math.random(1,#players)
Protector = players[num].Name
print('Protector is: ' ..Protector)
end

SelectPlayer2()

if Assassin == Protector then
SelectPlayer2()
end

if Assassin == Protector then
SelectPlayer2()
end

if Assassin == Protector then
SelectPlayer2()
end

if Assassin == Protector then
SelectPlayer2()
end

if Assassin == Protector then
SelectPlayer2()
end


function Sword(player)
player = game.Players:FindFirstChild(player)
Sword = game.ServerStorage.MidnightSword:clone()
if player~= nil then
Sword.Parent=player.Backpack
end
end

function Bow(player)
player = game.Players:FindFirstChild(player)
Bow = game.ServerStorage.DynamicallyLitBow:clone()
if player~= nil then
Bow.Parent=player.Backpack
end
end

Sword(Assassin)
Bow(Protector)

end)

AssassinPlayer = game.Workspace:FindFirstChild(Assassin)

if AssassinPlayer.Humanoid.Health == 0 then
game.ServerStorage["Victims Won"]:Fire()
end

When I reset, it didn't fire the the event.

There are no errors in the script, either. Nothing in output; nothing. Why?

1 answer

Log in to vote
0
Answered by
acecateer 130
10 years ago

Use the 'Died' Event. Link to: Died (Event) - Roblox Wiki

Line 1 of code edited.

AssassinPlayer = Assassin.Character

AssasinPlayer:WaitForChild("Humanoid").Died:connect(function()
game.ServerStorage["Victims Won"]:Fire()
end)

0
It says "WaitForChild called on an Instance that is not a DataModel" LennyTheLucario 45 — 10y
0
Change 'Game.Workspace:FindFirstChild(Assassin)' to 'Assassin.Character' acecateer 130 — 10y
0
It still has that error. LennyTheLucario 45 — 10y
0
Look at lines 1-18, your error is there. acecateer 130 — 10y
0
Everything works perfectly. I can't find any errors there. LennyTheLucario 45 — 10y
Ad

Answer this question