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: Is there a way to remove a character when on death?

Previous Thread :: Next Thread 
evrydayman3 is not online. evrydayman3
Joined: 14 Jun 2012
Total Posts: 703
25 May 2017 02:58 AM
For example, You die and your character disappears.. How do i do that?
Report Abuse
BStandsForBuilding is not online. BStandsForBuilding
Joined: 06 Apr 2015
Total Posts: 651
25 May 2017 03:44 AM
--Local script inside of starter pack.

local plr = game.Players.LocalPlayer
local chr = game.Workspace:WaitForChild(plr.Name)
local hum = chr:WaitForChild("Humanoid")

hum.Died:connect(function()
chr:Destroy()
end)

That should do it, can't check it.
Report Abuse
sircfenner is not online. sircfenner
Joined: 29 Aug 2008
Total Posts: 2430
25 May 2017 03:47 AM
You should use a server script (regular 'Script' object) for this in order to ensure FE compatibility. To make this apply to all characters, do the following:

-- Script in ServerScriptService

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
Character.Humanoid.Died:Connect(function()
wait(1) -- So it doesn't immediately disappear?
Character:Destroy()
end)
end)
end)
Report Abuse
Milenveliki is not online. Milenveliki
Joined: 14 Aug 2013
Total Posts: 1097
25 May 2017 05:00 AM
wait()if script.Parent.className~='Model'then script.Parent=Game.StarterPlayer.StarterCharacterScripts
for i,v in pairs(Workspace:GetChildren())do
if Game:service'Players':getPlayerFromCharacter(v)then
Game:service'Players':getPlayerFromCharacter(v):LoadCharacter()
end
end
else
script.Parent.Humanoid.Died:connect(function()wait()script.Parent:destroy()
end)
end
Report Abuse
LaeMVP is online. LaeMVP
Joined: 24 Jun 2013
Total Posts: 4416
25 May 2017 05:08 AM
Can anyone else spot the 4 deprecated functions in his script?
Report Abuse
Milenveliki is not online. Milenveliki
Joined: 14 Aug 2013
Total Posts: 1097
25 May 2017 05:10 AM
:P
Report Abuse
BStandsForBuilding is not online. BStandsForBuilding
Joined: 06 Apr 2015
Total Posts: 651
25 May 2017 11:57 AM
SirC's is much more efficient than what I posted and sets up a stronger framework. I'd advise you use that.
Report Abuse
Unsubtleties is not online. Unsubtleties
Joined: 28 Nov 2016
Total Posts: 9203
25 May 2017 12:00 PM
Or instead of connecting another event:

Character.Humanoid.Died:Wait()
Character:Destroy()


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