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: My game hates me...

Previous Thread :: Next Thread 
scripteer is not online. scripteer
Joined: 11 Mar 2011
Total Posts: 67
14 Apr 2012 08:47 PM
The output says that H is a nil value, yet It was given a purpose right before.

Human = Player.Name
H = Workspace:findFirstChild(Human)
H.Died:connect(function() Dead(Human, Player) end)
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
14 Apr 2012 08:48 PM
if H == nil then return end
Report Abuse
scripteer is not online. scripteer
Joined: 11 Mar 2011
Total Posts: 67
14 Apr 2012 08:54 PM
function Join(Player)
local l = Instance.new("IntValue")
l.Name = "leaderstats"
l.Parent = Player

local p = Instance.new("IntValue")
p.Name = "Points"
p.Parent = l
p.Value = 0

Human = Player.Name
H = Workspace:findFirstChild(Human)
if H == nil then return end
H.Died:connect(Dead)
end


Is this how i would put it? Should I move something, because my game wont recognize that someone has died.
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
14 Apr 2012 08:54 PM
Give it time for the character to load first.
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
14 Apr 2012 08:55 PM
while true do
wait(5)
if H == nil then return end
end
Report Abuse
scripteer is not online. scripteer
Joined: 11 Mar 2011
Total Posts: 67
14 Apr 2012 08:55 PM
How much time? would 10 seconds be enough?
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
14 Apr 2012 08:56 PM
function Join(Player)
local l = Instance.new("IntValue")
l.Name = "leaderstats"
l.Parent = Player

local p = Instance.new("IntValue")
p.Name = "Points"
p.Parent = l
p.Value = 0

Human = Player.Name
H = Workspace:findFirstChild(Human)

while true do
wait(5)
if H == nil then return end
end

H.Died:connect(Dead)
end


Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
14 Apr 2012 08:56 PM
5 to 10 yeah.
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
14 Apr 2012 08:57 PM
function Join(Player)
local l = Instance.new("IntValue")
l.Name = "leaderstats"
l.Parent = Player

local p = Instance.new("IntValue")
p.Name = "Points"
p.Parent = l
p.Value = 0

Human = Player.Name
H = Workspace:findFirstChild(Human)

while true do
wait(5)
if H == nil then
return
else
break
end
end

H.Died:connect(Dead)
end

Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
14 Apr 2012 09:05 PM
OR somthing better:

function Join(Player)
local l = Instance.new("IntValue")
l.Name = "leaderstats"
l.Parent = Player
local p = Instance.new("IntValue")
p.Name = "Points"
p.Parent = l
p.Value = 0
Player.CharacterAdded:connect(function(char)
char:FindFirstChild("Humanoid").Died:connect(Dead)
end

† KMXD †
Report Abuse
scripteer is not online. scripteer
Joined: 11 Mar 2011
Total Posts: 67
14 Apr 2012 09:10 PM
So, It still wont acknowledge that Ive died, ive started messing around and using prints but it wont reach the point of starting the dead function

Here's what I added, it wont reach the spot that says "done looping", do you know why?



function Join(Player)
local l = Instance.new("IntValue")
l.Name = "leaderstats"
l.Parent = Player

local p = Instance.new("IntValue")
p.Name = "Points"
p.Parent = l
p.Value = 0

Human = Player.Name
H = Workspace:findFirstChild(Human)
while true do
print "here"
wait(5)
print "done"
if H == nil then return print "looping" end
print "done looping" -- It will not print this
H.Died:connect(Dead)
end
end
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
14 Apr 2012 09:12 PM
Oops.

Game.Players.PlayerAdded:connect(function(Player)
local l = Instance.new("IntValue")
l.Name = "leaderstats"
l.Parent = Player
local p = Instance.new("IntValue")
p.Name = "Points"
p.Parent = l
p.Value = 0
Player.CharacterAdded:connect(function(char)
char:FindFirstChild("Humanoid").Died:connect(Dead)
end)
end)

† KMXD †
Report Abuse
scripteer is not online. scripteer
Joined: 11 Mar 2011
Total Posts: 67
14 Apr 2012 09:16 PM
So I tried your script as well, it says it needs a closing parenthesis, and when I put it in, it said there was an unexpected symbol where I put it, which was right after (Dead)
Report Abuse
1pie23 is not online. 1pie23
Joined: 11 Jul 2010
Total Posts: 1865
14 Apr 2012 09:18 PM
Why not keep my less-efficient script for a backup?
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
14 Apr 2012 09:21 PM
Can we see the Dead function? I believe the problem must be in that.
Report Abuse
scripteer is not online. scripteer
Joined: 11 Mar 2011
Total Posts: 67
14 Apr 2012 09:23 PM
Heres the Dead function

function Dead(Human, Player)
stats = Player:findFirstChild("leaderstats")
if stats ~= nil then
if Alive ~= nil then
Alive:remove()
end
end
end
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
14 Apr 2012 09:27 PM
Alright, try this:

game.Players.PlayerAdded:connect(function(Player)
Player.CharacterAdded:connect(function(char)
local l = Instance.new("IntValue")
l.Name = "leaderstats"
l.Parent = Player
local p = Instance.new("IntValue")
p.Name = "Points"
p.Parent = l
p.Value = 0
local humanoid = char:FindFirstChild("Humanoid")
if humanoid then
humanoid.Died:connect(function()
stats = Player:findFirstChild("leaderstats")
if stats ~= nil then
if Alive ~= nil then
Alive:remove()
end
end
end)
end
end)
end)
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
14 Apr 2012 09:31 PM
And get rid of the Dead function, it's taken care of now.
Report Abuse
scripteer is not online. scripteer
Joined: 11 Mar 2011
Total Posts: 67
14 Apr 2012 09:31 PM
I would say thanks, but even it didnt work... This is really starting to frustrate me, I dont know how far it got, but it did not remove the "Alive", and upon respawn I got another leaderstats.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
14 Apr 2012 09:32 PM
@Electric

Wouldn't that make more IntValues, everytime you die?

† KMXD †
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
14 Apr 2012 09:33 PM
Did you define stats and Alive?

Game.Players.PlayerAdded:connect(function(Player)
local l = Instance.new("IntValue")
l.Name = "leaderstats"
l.Parent = Player
local p = Instance.new("IntValue")
p.Name = "Points"
p.Parent = l
p.Value = 0
Player.CharacterAdded:connect(function(char)
local humanoid = char:FindFirstChild("Humanoid")
if humanoid then
humanoid.Died:connect(function()
stats = Player:findFirstChild("leaderstats")
if stats ~= nil then
if Alive ~= nil then
Alive:remove()
end
end
end)
end
end)
end)

† KMXD †
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
14 Apr 2012 09:35 PM
@KnightmareXD -

    humanoid.Died:connect(function()
    stats = Player:findFirstChild("leaderstats")
    if stats ~= nil then
    if Alive ~= nil then
    Alive:remove()
    end
    end
    end)

Where in that does it add more leaderstats? I copied his dead function into that.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
14 Apr 2012 09:36 PM
You put the characteradded event before instancing the intvalues.

† KMXD †
Report Abuse
scripteer is not online. scripteer
Joined: 11 Mar 2011
Total Posts: 67
14 Apr 2012 09:37 PM
oh, my, god, I feel so stupid for not noticing that, you pointed it out, I had it just written as Alive, where is should have been Player.Alive.
Report Abuse
ElectricBlaze is not online. ElectricBlaze
Joined: 18 Jul 2011
Total Posts: 22930
14 Apr 2012 09:40 PM
@KnightmareXD - Oh, now that you've rephrased it, I see it. Sorry, when you said "died", I thought you were referring to the Died event, not the CharacterAdded one.
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