|
| 10 Oct 2016 09:50 PM |
im trying to detect if when i die (just me, not "i" as in the player)
it'll take a brick out of ServerStorage and remove it 10 seconds later
can you help me see where i'm wrong?
function GetPlayer(p) function OnDied() local x = game.ServerStorage:findFirstChild("nowihaveyouDeath"):clone() x.Parent = game.Workspace wait(10) game.Workspace.nowihaveyouDeath:Destroy() end
p.Character.Humanoid.Died:connect(OnDied)
end
game.Players.nowihaveyou.PlayerAdded:connect(GetPlayer)
|
|
|
| Report Abuse |
|
|
|
| 10 Oct 2016 09:53 PM |
Instead of:
local x = game.ServerStorage:findFirstChild("nowihaveyouDeath"):clone() x.Parent = game.Workspace wait(10) game.Workspace.nowihaveyouDeath:Destroy()
Use:
local x = game.ServerStorage:findFirstChild("nowihaveyouDeath"):clone() x.Parent = game.Workspace wait(10) game:GetService('Debris"):AddItem(x,10) <----- Ads the brick to workspace, then removes it after 10 seconds.
Mind if you post the output? |
|
|
| Report Abuse |
|
|
|
| 10 Oct 2016 09:59 PM |
sure I changed it as you recommended so the final script is now
function GetPlayer(p) function OnDied() local x = game.ServerStorage:findFirstChild("nowihaveyouDeath"):clone() x.Parent = game.Workspace wait(10) game:GetService("Debris"):AddItem(x,10) end
p.Character.Humanoid.Died:connect(OnDied)
end
game.Players.nowihaveyou.PlayerAdded:connect(GetPlayer)
the output only mentions line 15
22:58:00.706 - Stack Begin 22:58:00.706 - Script 'Workspace.Script', Line 15 22:58:00.707 - Stack End |
|
|
| Report Abuse |
|
|
|
| 10 Oct 2016 10:07 PM |
| Make a ModuleScript, place it in workspace. In the Module script, copy and paste this code: local module = {} module.Died = ####################### ########################## "Has died!") end return module Make a Regular Script. Place it in StarterPlayers > StarterCharacterScripts In the regular script, copy and paste this code: local Module = require(game.workspace.ModuleScript) ############################################## Module.Died(script.Parent) end) This is the easiest way for me. Hope it works! |
|
|
| Report Abuse |
|
|