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:

Previous Thread :: Next Thread 
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
08 Mar 2015 09:28 PM
local function SetupCharacter()
if HumanoidDiedEvent then
print("it exists")
HumanoidDiedEvent:disconnect()
HumanoidDiedEvent = nil
end
if Player:IsDescendantOf(Players) then--make sure the player is present
while not (Player.Character and --wait for player to load.
Player.Character:FindFirstChild("Humanoid") and
Player.Character.Humanoid:IsA("Humanoid")) do
wait()
end
Character = Player.Character
HumanoidDiedEvent = Player.Character.Humanoid.Died:connect(function()
print'called'
wait(Configuration.SpawnDelay)
if Player:IsDescendantOf(Players) then --recheck the player's presence
Player:LoadCharacter()
end
end)
end
end
InitialLoad()
SetupCharacter()
Player.CharacterAdded:connect(SetupCharacter)

in specific,

HumanoidDiedEvent = Player.Character.Humanoid.Died:connect(function()
print'called'
wait(Configuration.SpawnDelay)
if Player:IsDescendantOf(Players) then --recheck the player's presence
Player:LoadCharacter()
end
end)

It doesn't print called. It doesn't seem to execute when died is called.
However, when I print HumanoidDiedEvent, it is indeed a connection, and using the command bar, I can connect to it fine.
Why is it having problems here in specific? Everything around it prints just fine.

-=Robo=-
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
08 Mar 2015 09:28 PM
Woah, it actually tabbed over
wasn't expecting that lol

-=Robo=-
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
08 Mar 2015 09:36 PM
eh

-=Robo=-
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
08 Mar 2015 09:43 PM
seriously about to run through a wall impatience intensifies impatience leveled up 10/10 20/20 mode golden froodie brody is disgusting

-=Robo=-
Report Abuse
Darkmist101 is not online. Darkmist101
Joined: 30 Jul 2010
Total Posts: 6208
08 Mar 2015 10:02 PM
http://wiki.roblox.com/index.php?title=API:Class/Player/CharacterAdded
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
08 Mar 2015 10:05 PM
Did you not read the thread, or what?
My problem doesn't have anything to do with CharacterAdded. Thanks for the bump, though. lol

-=Robo=-
Report Abuse
DrJonJ is not online. DrJonJ
Joined: 18 Nov 2009
Total Posts: 2361
08 Mar 2015 10:06 PM
Just winging it.... But try adding "HumanoidDiedEvent" after defining it?
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
08 Mar 2015 10:10 PM
full function;

local function SetupPlayer(Player)
local HumanoidDiedEvent
local Character

local function InitialLoad() --I'd imagine you only call this once. Obviously.
if Configuration.SpawnDelayEnabled then
Player:LoadCharacter()
print("character loaded")
end
--create the player's code bin;
local bin = Instance.new("Backpack", Player)
bin.Name = Configuration.BinName
MoveFrom(BrainmatterClient, bin, "LuaSourceContainer", true, true,
function(obj)
if obj.Disabled then
obj.Disabled = false
end
end)
end

local function SetupCharacter(Character)
if HumanoidDiedEvent then
print("it exists")
HumanoidDiedEvent:disconnect()
HumanoidDiedEvent = nil
end
if Player:IsDescendantOf(Players) then--make sure the player is present
while not (Character and --wait for player to load.
Character:FindFirstChild("Humanoid") and
Character.Humanoid:IsA("Humanoid")) do
wait()
end
HumanoidDiedEvent = Character.Humanoid.Died:connect(function()
print'called'
wait(Configuration.SpawnDelay)
if Player:IsDescendantOf(Players) then --recheck the player's presence
Player:LoadCharacter()
end
end)
end
end
InitialLoad()
SetupCharacter(Player.Character)
Player.CharacterAdded:connect(SetupCharacter)
end

wait()
for _, player in pairs(Players:GetPlayers()) do
SetupPlayer(player)
end

Players.PlayerAdded:connect(SetupPlayer)

-=Robo=-
Report Abuse
DrJonJ is not online. DrJonJ
Joined: 18 Nov 2009
Total Posts: 2361
08 Mar 2015 10:19 PM
If I'm reading that right, then every time it gets called, it re-executes it for all players. Which in turn re-executes it for all players?

You really should break that down into functions OUTSIDE of it if you can.
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
08 Mar 2015 10:24 PM
Nah, you're reading it wrong.
It executes for all players currently in the server, waits, and then connects it to the PlayerAdded event. That's still not the problem.
Everything seems to work fine except the pseudo function, and I really can't figure out why.

-=Robo=-
Report Abuse
DrJonJ is not online. DrJonJ
Joined: 18 Nov 2009
Total Posts: 2361
08 Mar 2015 10:25 PM
FYI, it's called anonymous function.

And that may be in fact why it errors out.

Try placing that function outside of it and not being anonymous.
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
08 Mar 2015 10:28 PM
I know the terminology. I've just made a bad habit of using the word "pseudo" a lot, lol
And alright, I did. It doesn't seem to make a difference.

-=Robo=-
Report Abuse
DrJonJ is not online. DrJonJ
Joined: 18 Nov 2009
Total Posts: 2361
08 Mar 2015 10:30 PM
Hah. Found it!

I love that 'Character' isn't defined. (In second posted code)
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
08 Mar 2015 10:31 PM
printed the "connected" property of the RBXScriptSignal, it is indeed connected lol

-=Robo=-
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
08 Mar 2015 10:32 PM
Character is passed in CharacterAdded, isn't it?
http://wiki.roblox.com/index.php?title=CharacterAdded

-=Robo=-
Report Abuse
DrJonJ is not online. DrJonJ
Joined: 18 Nov 2009
Total Posts: 2361
08 Mar 2015 10:33 PM
Fairly certain in your second code you did NOT define Character. I used Ctrl+F to check.
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
08 Mar 2015 10:45 PM
i did o.o

-=Robo=-
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
08 Mar 2015 10:52 PM
Character is a parameter passed by CharacterAdded, it's used by SetupCharacter. I forgot to remove "local Character" at the top of the code.

-=Robo=-
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
08 Mar 2015 10:53 PM
Though the function listening for the died signal still isn't executing. There is no error, and there is no reason to be; the code in it isn't executing and I can't figure out why. I don't know how else to explain it, I can't see anything I'm doing wrong and it's getting to me lol

-=Robo=-
Report Abuse
LucasLua is not online. LucasLua
Joined: 18 Jun 2008
Total Posts: 7386
08 Mar 2015 11:09 PM
Try using a different event like HealthChanged or some sort.
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
08 Mar 2015 11:41 PM
I don't WANT to use a different event. I mean, I'm willing to even rewrite this portion, I just want to know why it's not executing.

-=Robo=-
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
09 Mar 2015 12:25 AM
seeing as seranok is active right now, bump

-=Robo=-
Report Abuse
Seranok is not online. Seranok
Joined: 12 Dec 2009
Total Posts: 11083
09 Mar 2015 12:32 AM
Your code is about 3x as complex as it needs to be. There's no need to explicitly disconnect the Humanoid.Died connection, it will be automatically disconnected by the engine.

It would help if you explained what you are trying to do. Set up a custom spawn system for some reason?
Report Abuse
robocu3 is not online. robocu3
Joined: 13 Mar 2009
Total Posts: 6485
09 Mar 2015 12:34 AM
that is exactly what I'm trying to do. I wasn't aware that the engine would handle that, however, so my bad.
I'm making a framework, or an "engine". One of the options in configuration is to have a custom spawn delay or disable the spawn system all together.
However, this still doesn't really explain why the code in the HumanoidDiedEvent isn't executing, and I really want to know why lol

-=Robo=-
Report Abuse
Seranok is not online. Seranok
Joined: 12 Dec 2009
Total Posts: 11083
09 Mar 2015 12:36 AM
The way to debug this is to put a print statement on basically every line. That way you can trace how far your program gets and see where the problem is occurring.
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