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

Will this script work?

Asked by 10 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

It's a script that when you die, it creates a smoke effect, one that's supposed to be red. But I don't know if this works, and everytime I try to test it, my camera goes flying off into space for some reason.

local player = game.Players.LocalPlayer

function ConnectOnDeath()
local s =  instance.new("Smoke")
s.Size = 5
s.Parent = player.Character.Torso
s.Heat = 10

if player.Character.Humanoid.Health == 0 then
ConnectOnDeath()
end
end

1 answer

Log in to vote
1
Answered by 10 years ago

No for a couple reasons. You are never calling the ConnectOnDeath function from outside itself, so it never triggers it. Secondly the way you are calling it inside itself would only work if the character's health was at 0 the time it triggered, and never again. Which is highly unlikely. To fix it you need to do this:

local player = game.Players.LocalPlayer

function ConnectOnDeath()
    local s =  instance.new("Smoke")
    s.Size = 5
    s.Parent = player.Character.Torso
    s.Heat = 10
end
player.Character.Humanoid.Died:connect(ConnectOnDeath);
Ad

Answer this question