generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Get Humanoid through variable (Updated)

Previous Thread :: Next Thread 
Krosskode is not online. Krosskode
Joined: 26 Aug 2010
Total Posts: 11001
05 Jul 2014 07:54 PM
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?
Report Abuse
Krosskode is not online. Krosskode
Joined: 26 Aug 2010
Total Posts: 11001
05 Jul 2014 08:38 PM
help?
Report Abuse
Krosskode is not online. Krosskode
Joined: 26 Aug 2010
Total Posts: 11001
06 Jul 2014 12:25 PM
Maybe someone can help.
Report Abuse
SuperNintendo is not online. SuperNintendo
Joined: 02 Dec 2007
Total Posts: 223
06 Jul 2014 01:31 PM
Someone should help this kid.
Report Abuse
Krosskode is not online. Krosskode
Joined: 26 Aug 2010
Total Posts: 11001
06 Jul 2014 04:07 PM
@SuperNintendo
uhm
cool
Report Abuse
SuperNintendo is not online. SuperNintendo
Joined: 02 Dec 2007
Total Posts: 223
06 Jul 2014 05:31 PM
I agree.
Report Abuse
SuperNintendo is not online. SuperNintendo
Joined: 02 Dec 2007
Total Posts: 223
06 Jul 2014 06:52 PM
I approve OP's game.
Report Abuse
Krosskode is not online. Krosskode
Joined: 26 Aug 2010
Total Posts: 11001
06 Jul 2014 11:48 PM
Uhm, okay?
Report Abuse
Krosskode is not online. Krosskode
Joined: 26 Aug 2010
Total Posts: 11001
07 Jul 2014 10:14 PM
Help?
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
07 Jul 2014 10:26 PM
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)

game.Workspace:FindFirstChild(Assassin).Humanoid.Died:connect(function()
game.ServerStorage["Victims Won"]:Fire()
end)
Report Abuse
Krosskode is not online. Krosskode
Joined: 26 Aug 2010
Total Posts: 11001
07 Jul 2014 11:56 PM
It just says in the output

Error: GameScript2 Line 72

which is

game.Workspace:FindFirstChild(Assassin).Humanoid.Died:connect(function()
Report Abuse
StingyShaun is not online. StingyShaun
Joined: 30 Oct 2011
Total Posts: 395
08 Jul 2014 12:02 AM
You forgot some quotations/" " around assassin
Report Abuse
Krosskode is not online. Krosskode
Joined: 26 Aug 2010
Total Posts: 11001
08 Jul 2014 12:13 AM
I thought you don't need quotations to reference variables.
Report Abuse
StingyShaun is not online. StingyShaun
Joined: 30 Oct 2011
Total Posts: 395
08 Jul 2014 12:16 AM
Well if the script isn't working, I suggest giving it a try
Report Abuse
Casualist is not online. Casualist
Joined: 26 Jun 2014
Total Posts: 4443
08 Jul 2014 02:46 AM
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)

Assassin.Humanoid.Died:connect(function()
game.ServerStorage["Victims Won"]:Fire()
end)
Report Abuse
Krosskode is not online. Krosskode
Joined: 26 Aug 2010
Total Posts: 11001
08 Jul 2014 11:44 PM
Same line.

00:43:23.853 - ServerScriptService.GameScript2:72: attempt to index global 'Assassin' (a nil value)
00:43:23.855 - Script 'ServerScriptService.GameScript2', Line 72
00:43:23.856 - ServerScriptService.Script:1: attempt to index global 'character' (a nil value)
Report Abuse
Krosskode is not online. Krosskode
Joined: 26 Aug 2010
Total Posts: 11001
12 Jul 2014 04:43 PM
Bump
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image