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

Why does my LocalScript only fire once?

I have this in a LocalScript

humanoid.Died:connect(function(Died)
	for i, v in pairs(game.Players:GetChildren()) do
		if v.TeamColor == BrickColor.new('Bright red') and v.Character.Humanoid.Health == 0 then
    		print('Red has died')	
		event:FireServer()
		end
	end
end)

However if I reset my character again while still meeting the conditions, nothing happens. If I check and uncheck the Disabled property on the script and reset, it works....why is it doing this?

2 comments

0

Try wrappping the whole thing in a .CharacterAdded event.

0

That would be okay in a LocalScript?

1 answer

im confused. if its a local script you can go and do game.Players.LocalPlayer.Character

game.Players.LocalPlayer.Character.Humanoid.Died:connect(function(Died)
        if game.Players.LocalPlayer.TeamColor == BrickColor.new('Bright red') and game.Players.LocalPlayer.Character.Humanoid.Health == 0 then
        	print('Red has died')   
        	event:FireServer()
        end
end)

2 comments

0

I wasn't sure whether or not I could do that. I always see people saying, don't put stuff in here, don't put stuff in there, and I am sort of afraid of experimenting for fear of doing something wrong.

0

@ConnorVIII I tried it with that and it still does not work sadly.

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