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 » Scripters
Home Search
 

Re: Why does this keep sending me nil?

Previous Thread :: Next Thread 
Klink45 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
20 Jul 2016 12:24 AM
local peoplealive = game.ServerScriptService:WaitForChild("Main"):WaitForChild("PeopleAlive")
local sheriff = peoplealive.Parent:WaitForChild("Sheriff")
local memer = peoplealive.Parent:WaitForChild("Memer")
humanoid.Died:connect(function()
_G.EndRound("Innocent", memer, sheriff)
end)

EVERY DARN TIME THE LAST TWO ARGUMENTS ARE NIL, AND I GET THIS ERROR:

attempt to index local 'sheriff' (a nil value)

And the same for memer.

What on Earth? I am sure they are not nil so why is this happening?

u sicko!
Report Abuse
HeIIoISteaIUsernames is not online. HeIIoISteaIUsernames
Joined: 26 Oct 2012
Total Posts: 2906
20 Jul 2016 12:26 AM
the mad memer


leoleoeoeel
Report Abuse
Klink45 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
20 Jul 2016 12:27 AM
@Hello
Seriously: https://www.roblox.com/games/252336261/Alpha-COMING-SOON-The-Mad-Memer

Also seriously, why is it sending nil?

u sicko!
Report Abuse
HeIIoISteaIUsernames is not online. HeIIoISteaIUsernames
Joined: 26 Oct 2012
Total Posts: 2906
20 Jul 2016 12:30 AM
can i see the variable for "Innocent"?
Report Abuse
Klink45 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
20 Jul 2016 12:35 AM
I don't need one for innocent, this script goes inside the Memer's humanoid so I can easily keep track of him dying.

This is the whole script:

local character = script.Parent.Parent
local humanoid = script.Parent
local peoplealive = game.ServerScriptService:WaitForChild("Main"):WaitForChild("PeopleAlive")
local sheriff = peoplealive.Parent:WaitForChild("Sheriff")
local memer = peoplealive.Parent:WaitForChild("Memer")
humanoid.Died:connect(function()
print(memer.Value)
print(sheriff.Value)
_G.EndRound("Innocent", memer, sheriff)
end)

peoplealive.Changed:connect(function()
if peoplealive.Value == 1 and humanoid.Health >0 then
_G.EndRound("Memer", memer, sheriff)
end
end)

Basically when I use the arguments in my global script (Which will be turned into modules after I fix this) it acts like sheriff and memer are nil.

u sicko!
Report Abuse
HeIIoISteaIUsernames is not online. HeIIoISteaIUsernames
Joined: 26 Oct 2012
Total Posts: 2906
20 Jul 2016 12:39 AM
can you try and do this?
local peoplealive = game.ServerScriptService:WaitForChild("Main").PeopleAlive
Report Abuse
Klink45 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
20 Jul 2016 12:42 AM
Still returns the same error.

Here's the function if it helps:

_G.EndRound = function(winner, memer, sheriff)
print(sheriff.Value)--Returns error.
game.ServerScriptService.Main.PeopleAlive.Value = false
local lobby = game.Workspace.Lobby
--local winner = game.ServerScriptService.Main.Winner
for i, l in pairs(lobby:GetChildren()) do
if l:IsA("BasePart") then
l.BrickColor = BrickColor.Random()
elseif l:IsA("Model") then
for i, m in pairs(l:GetChildren()) do
if m:IsA("BasePart") then
m.BrickColor = BrickColor.Random()
end
end
end
end
for i,v in pairs(game.Workspace:GetChildren()) do
if game.Players:FindFirstChild(v.Name) ~= nil then
v.Humanoid.Health = 0
end
end
game.ServerScriptService.Main.PeopleAlive.Value = 0
wait(8)
for i,v in pairs(game.Players:GetPlayers()) do
local frame = v.PlayerGui.Winner.Frame
frame.Sheriff.Value = sheriff.Value
frame.Memer.Value = memer.Value
frame.Visible = true
frame.WhoWon.Text = "The "..winner.." won!"
if winner == "Nobody" then
frame.WhoWon.Text = "Nobody won!"
end
end
end

u sicko!
Report Abuse
Raphael7 is not online. Raphael7
Joined: 03 Dec 2008
Total Posts: 2479
20 Jul 2016 12:56 AM
What class is the sheriff?
Report Abuse
Klink45 is not online. Klink45
Joined: 06 Jun 2011
Total Posts: 26054
20 Jul 2016 12:59 AM
They're both ObjectValues.

I'm starting to wonder if it is because I'm using global functions...

u sicko!
Report Abuse
StrongNuclear is not online. StrongNuclear
Joined: 05 Mar 2016
Total Posts: 963
20 Jul 2016 01:15 AM
If you are using _G to interact between client and server in fe it won't work.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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