So I’m a beginner scripter with about six months of experience by now, and I decided to write my very first code all by myself without a tutorial. Hurray!
So I decided that when a person touches this alarm brick thing, the lights flash red and white. When that specific person dies, then everything goes back to normal.
So I test it and everything is working except that the lights aren’t flashing. They flash once and then they stop. Here’s that bit:
@NoodleCrystalHaden10, Perhaps this could work to replace that bit of code (repeat until can be iffy):
while player.Character.Humanoid.Died == false do
wait(0.5)
securitylite.Color = Color3.new(170,0,0)
securityliteB.Color = Color3.new(170,0,0)
wait(0.5)
securitylite.Color = Color3.new(255,255,255)
securityliteB.Color = Color3.new(255,255,255)
end
Also, I noticed you did player.Humanoid.Died, even though Humanoid is inside of the player’s Character. Assuming your player variable is the player object, you’ll want to do player.Character.Humanoid, not player.Humanoid.
The “player” variable is actually the physical part. The one in Workspace, not Players (is it PlayerService?) So the format would go; game.Workspace. (here is the player). Humanoid (there’s no character before it)
I just realized what the problem is. Humanoid.Died is an event, not something that returns a boolean value. Thus, if you want to check if the player is still alive, you can do it directly by checking their health. Here’s the new code:
print("First")
while player.Character.Humanoid.Health > 0 do
print("Second")
wait(0.5)
securitylite.Color = Color3.new(170,0,0)
securityliteB.Color = Color3.new(170,0,0)
wait(0.5)
securitylite.Color = Color3.new(255,255,255)
securityliteB.Color = Color3.new(255,255,255)
end