Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Part isnt getting created on death?

When an enemy dies, it is supposed to make a red part get created.

function onDied()
	redgem = Instance.new("Part",game.Workspace.GemDropStorage)
	redgem.Size = Vector3.new(1,1,1)
	redgem.Material = "Neon"
	redgem.BrickColor = BrickColor.new("Really red")
end

when i get a sword, and kill the enemy, the part doesent get created!

the enemy is a working humanoid that moves around

1 answer

✓ Accepted answer

You have created the function but you aren't calling it

To call a function you would do

functionname()

We want to run this function when the character dies so we will use the Died event of humanoid to call it

local character = workspace.Player

character:WaitForChild("Humanoid").Died:connect(function() --waitforchild to make sure its there
	redgem = Instance.new("Part",game.Workspace.GemDropStorage)
	redgem.Size = Vector3.new(1,1,1)
	redgem.Material = "Neon"
	redgem.BrickColor = BrickColor.new("Really red")
end)

In this example i merged the function and where you call it together

5 comments

0

but its not the player who is dying

0

https://gyazo.com/a70934f27a98ead749900eae905f49de that is who is dying. you kill him and it makes a part

0

@AndrewTheRoblox as long as your character has a humanoid when it dies it will fire the Died event

0

You can change the character variable, it was just an example

0

thx

This discussion is preserved as it was. New answers, comments, and votes are closed.