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: Potato

Previous Thread :: Next Thread 
shadowlego7 is not online. shadowlego7
Joined: 03 Mar 2007
Total Posts: 2278
17 Jan 2013 07:44 PM
I want to be able to toggle it so that it doesn't run all the time. I need it for a section in my game as a failsafe incase the player leaves before something was supposed to happen.
Report Abuse
MeBilly8440 is not online. MeBilly8440
Joined: 27 Jul 2009
Total Posts: 2783
17 Jan 2013 07:49 PM
game.Players.PlayerRemoving:connect(function(player)
-- player is the Player that is leaving
end)
Report Abuse
shadowlego7 is not online. shadowlego7
Joined: 03 Mar 2007
Total Posts: 2278
17 Jan 2013 08:00 PM
Thank you MeBilly.

So, if this were in a LocalScript within a GUI, and I did this:
------------------------------------------------
p = game.Players.LocalPlayer

game.Players.PlayerRemoving:connect(function(p)
print ("goodbye" ..p.Character.Name)
end)
------------------------------------------------
It would work?
Report Abuse
MeBilly8440 is not online. MeBilly8440
Joined: 27 Jul 2009
Total Posts: 2783
17 Jan 2013 08:03 PM
Probably. I'm not sure about using their character once the event has been triggered. But you can find their name without that. So just to be safe, I'd make it:

p = game.Players.LocalPlayer

game.Players.PlayerRemoving:connect(function(p)
print ("goodbye" ..p.Name)
end)
Report Abuse
shadowlego7 is not online. shadowlego7
Joined: 03 Mar 2007
Total Posts: 2278
17 Jan 2013 08:08 PM
Alright. Thanks a lot, MeBilly. I really appreciate it.
Report Abuse
shadowlego7 is not online. shadowlego7
Joined: 03 Mar 2007
Total Posts: 2278
17 Jan 2013 08:11 PM
Hold on. I just thought of something. If I put this script in the player's GUI... wouldn't it not run if he leaves? Since the script is removed when he leaves?
Report Abuse
MeBilly8440 is not online. MeBilly8440
Joined: 27 Jul 2009
Total Posts: 2783
17 Jan 2013 08:13 PM
Well, in theory the player hasn't actually left yet, because the event has been triggered and it's giving your the player. But just to be save, I'd put it in a normal script in Workspace, if you can.
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
17 Jan 2013 08:15 PM
Whatever you do on the PlayerRemoving event when it's in the player's descendants has to be done in one frame. Because the next frame, the script will be destroyed and the code-thread won't exist anymore.
Report Abuse
shadowlego7 is not online. shadowlego7
Joined: 03 Mar 2007
Total Posts: 2278
17 Jan 2013 08:21 PM
The problem with that is that I need to be able to toggle the script at certain times. It only needs to work when I enable the script. Sorry for all the questions.

I don't actually need the player's name.

So, would it be consistant and safe enough if I just had the LocalScript in a GUI like this?:

p = game.Players.LocalPlayer

game.Players.PlayerRemoving:connect(function(p)
game.Workspace.LightheartedLvl2.LevelJump.NxtLvlPort.Disable.Value = false
end)
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
17 Jan 2013 08:21 PM
It would be safer to not do it locally.
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
17 Jan 2013 08:22 PM
Do you need the player? If not, then I see no point in putting it in the GUI.

¤ ¤ † K M X D † ¤ ¤
Report Abuse
shadowlego7 is not online. shadowlego7
Joined: 03 Mar 2007
Total Posts: 2278
17 Jan 2013 08:25 PM
@ Knightmare

It has to be toggle-able according to what the player did.

So, it would be better just to make it a normal script and have it to something like this?:


p = script.Parent.Parent.Parent

game.Players.PlayerRemoving:connect(function(p)
game.Workspace.LightheartedLvl2.LevelJump.NxtLvlPort.Disable.Value = false
end)
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
17 Jan 2013 08:26 PM
It would be "safer" for to be in the workspace and not specific to a player's descendants.
Report Abuse
shadowlego7 is not online. shadowlego7
Joined: 03 Mar 2007
Total Posts: 2278
17 Jan 2013 08:33 PM
Is it safe enough?
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
17 Jan 2013 08:35 PM
I suppose. Though in your most recent script, remove the declaration of the variable p. It's not needed.

¤ ¤ † K M X D † ¤ ¤
Report Abuse
shadowlego7 is not online. shadowlego7
Joined: 03 Mar 2007
Total Posts: 2278
17 Jan 2013 08:37 PM
Oh, thanks.
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
17 Jan 2013 08:37 PM
I'm just thinking the event won't even fire....
Report Abuse
KnightmareXD is not online. KnightmareXD
Joined: 14 Jul 2009
Total Posts: 11189
17 Jan 2013 08:44 PM
Assuming it's in Workpace, of course. I thought that when you asked if it was safe, you were talking about placing it inside of Workspace.

¤ ¤ † K M X D † ¤ ¤
Report Abuse
MeBilly8440 is not online. MeBilly8440
Joined: 27 Jul 2009
Total Posts: 2783
17 Jan 2013 08:50 PM
Ran with Tools -> Test -> Start Server & Tools -> Test -> Start Player
One script in Workspace: game.Players.PlayerRemoving:connect(function(player) Instance.new("Message", game.Workspace).Text = player.Name.." left!" end)
One LocalScript in StarterPack: game.Players.PlayerRemoving:connect(function(player) Instance.new("Part", game.Workspace).Anchored = true end)

> Leave with Player1
>> New message in Workspace, no new brick

Why didn't I just do that before posting? qq
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