Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Part isnt getting created on death?

Asked by 6 years ago
Edited 6 years ago

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

Log in to vote
0
Answered by
DanzLua 2879 Moderation Voter Community Moderator
6 years ago
Edited 6 years ago

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

0
but its not the player who is dying AndrewTheRoblox -6 — 6y
0
https://gyazo.com/a70934f27a98ead749900eae905f49de that is who is dying. you kill him and it makes a part AndrewTheRoblox -6 — 6y
0
@AndrewTheRoblox as long as your character has a humanoid when it dies it will fire the Died event DanzLua 2879 — 6y
0
You can change the character variable, it was just an example DanzLua 2879 — 6y
0
thx AndrewTheRoblox -6 — 6y
Ad

Answer this question