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: Run code after death

Previous Thread :: Next Thread 
S1lverjust is not online. S1lverjust
Joined: 30 May 2015
Total Posts: 36
26 Jun 2017 05:21 PM
I have a script in a tool. When the player dies, the script gets deleted and stopps running. I need this script to run a few functions for an unknown amount of time after the death of the player.
I could move this script somewhere safe, but how do I know when this script is finished? Is there a way to get information about the status of the script?
Or is there another way to solve this?
Report Abuse
Alexware is not online. Alexware
Joined: 07 May 2010
Total Posts: 661
26 Jun 2017 05:23 PM
it shouldn't disappear unless you instantly respawn...
script status is literally in the order of the lines
once it gets to the bottom line it's done
add script:Destroy() to the bottom line to remove it when it's done.
Report Abuse
helloburp is not online. helloburp
Joined: 26 Aug 2011
Total Posts: 14376
26 Jun 2017 05:27 PM
Humanoid.Died
Report Abuse
ahwz is not online. ahwz
Joined: 01 Apr 2010
Total Posts: 3230
26 Jun 2017 05:30 PM
CharacterAdded event


Report Abuse
S1lverjust is not online. S1lverjust
Joined: 30 May 2015
Total Posts: 36
26 Jun 2017 06:52 PM
I want to know when the script has ended, not when the humanoid died.
And the script is a bit more complicated, I have it spawn threads, and I dont know when they will finish.
Report Abuse
S1lverjust is not online. S1lverjust
Joined: 30 May 2015
Total Posts: 36
27 Jun 2017 07:56 AM
Or is there a way to transfere or move the threads to another script? This would solve the problem too
Report Abuse
BreggFast is online. BreggFast
Joined: 04 Jul 2016
Total Posts: 14
27 Jun 2017 08:03 AM
Debounce.

running = true

while running do

dowhatthescriptsays()

running = false

end

print("I am done")

something like that
Report Abuse
S1lverjust is not online. S1lverjust
Joined: 30 May 2015
Total Posts: 36
27 Jun 2017 12:09 PM
And how exactly would debounce help me with this problem?
Report Abuse
ad_zz is not online. ad_zz
Joined: 11 Jun 2011
Total Posts: 385
27 Jun 2017 12:31 PM
so u can check if the scripts still running
Report Abuse
S1lverjust is not online. S1lverjust
Joined: 30 May 2015
Total Posts: 36
27 Jun 2017 01:03 PM
The problem is, the script stops running when its deleted.
how do I move the process/thread to another script, so it can continue?
I could also move the entire script, but then I have to know when all the threads have ended to remove it
Report Abuse
WXBZ is not online. WXBZ
Joined: 10 Oct 2012
Total Posts: 850
27 Jun 2017 01:59 PM
That is because your script is in the character.


for _, post in pairs(game.Players.WXBZ.Posts:GetChildren()) do post.Signature.Text = 'scripters.cf' end
Report Abuse
LogicalProcess is not online. LogicalProcess
Joined: 01 Dec 2010
Total Posts: 1453
27 Jun 2017 01:59 PM
wxbz is bad


This is an automated signatiure. Current project, GSR
Report Abuse
WXBZ is not online. WXBZ
Joined: 10 Oct 2012
Total Posts: 850
27 Jun 2017 02:02 PM
Fight me on the server.


for _, post in pairs(game.Players.WXBZ.Posts:GetChildren()) do post.Signature.Text = 'scripters.cf' end
Report Abuse
JoshRBX is not online. JoshRBX
Joined: 19 May 2012
Total Posts: 8778
27 Jun 2017 02:03 PM
am bad
Report Abuse
M_org is not online. M_org
Joined: 19 Sep 2013
Total Posts: 231
27 Jun 2017 02:30 PM
cba to write code

- PlayerAdded event
- add a character added event
- find humanoid with char
- check to see if dead

- do all your fancy scripting


R$30
Report Abuse
Lua_Basics is not online. Lua_Basics
Joined: 04 Jun 2012
Total Posts: 9977
27 Jun 2017 02:32 PM
.changed ?
Report Abuse
M_org is not online. M_org
Joined: 19 Sep 2013
Total Posts: 231
27 Jun 2017 02:33 PM
@Lua,

I think .Changed only works for values...


R$30
Report Abuse
Lua_Basics is not online. Lua_Basics
Joined: 04 Jun 2012
Total Posts: 9977
27 Jun 2017 02:33 PM
ahhh your silly
Report Abuse
Lua_Basics is not online. Lua_Basics
Joined: 04 Jun 2012
Total Posts: 9977
27 Jun 2017 02:34 PM
I've had to use some weird things to get stuff done my friend, experimentation is amazing.
Report Abuse
WeirdGuyHere is not online. WeirdGuyHere
Joined: 20 Oct 2012
Total Posts: 1349
27 Jun 2017 02:42 PM
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()

-- here you can write what ever your function is, OR you can call another function here.

end)
end)
end)


Report Abuse
WeirdGuyHere is not online. WeirdGuyHere
Joined: 20 Oct 2012
Total Posts: 1349
27 Jun 2017 02:44 PM
for example;

function onDead()
print(2+2)
end

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()

onDead()

end)
end)
end)


Report Abuse
WeirdGuyHere is not online. WeirdGuyHere
Joined: 20 Oct 2012
Total Posts: 1349
27 Jun 2017 02:45 PM
the function you called will continue running even if the original script gets deleted when the player respawns.


Report Abuse
S1lverjust is not online. S1lverjust
Joined: 30 May 2015
Total Posts: 36
27 Jun 2017 02:47 PM
I know that the script is in the character, but I can move it somewhere else, thats no problem.
The problem is: I want to delete this script, as soon as all the threads inside this script have finished.

with thread I mean:

spawn(function()
--stuff
end
)
or


local newThread = coroutine.create(function()
--stuff
end
)
coroutine.resume(newThread)

how do I know when all threads of one script have finished?
Report Abuse
WeirdGuyHere is not online. WeirdGuyHere
Joined: 20 Oct 2012
Total Posts: 1349
27 Jun 2017 02:49 PM
or, more efficient way you can put the function inside a modulescript located in scriptservice (for example)

the script in the tool would require that module, and call a function in the module when the player dies. the function will not stop even if the script is deleted because its located inside the module (which doesn't get deleted)

============================================

-- IN MODULE SCRIPT --

local module = {}

function module.onDead()
print(2+2)
end

return module

-- IN TOOL SCRIPT --

local module = require(game.ServerScriptService:FindFirstChild("ModuleScript"))

game:Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
module.onDead()
end)
end)
end)




Report Abuse
S1lverjust is not online. S1lverjust
Joined: 30 May 2015
Total Posts: 36
27 Jun 2017 02:51 PM
@WeirdGuyHere

Is there a way to just start a block of code like this, so it continues after death, but started befor they died?
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