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

Will this script work?

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

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);

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