1 | while true do |
2 | script.Parent.BrickColor = BrickColor.new( 255 , 0 , 0 ) |
3 | --KILL PLAYER FUNCTION-- |
4 | wait(math.random( 3 , 7 )) |
5 | script.Parent.BrickColor = BrickColor.new( 255 , 255 , 255 ) |
6 | wait(math.random( 3 , 7 )) |
7 | end |
Ive tried Disabling and Enabling a kill script(which didn't work). Ive also tried to put a function above the while true do loop that kills the player(didn't work again)
This didnt work:
01 | function Kill(part) --probably has to do with parameter |
02 | local hum = part.Parent:FindFirstChild( "Humanoid" ) |
03 | if hum ~ = nil then |
04 | hum.Health = 0 |
05 | end |
06 | end |
07 |
08 | script.Parent.Touched:Connect(Kill) |
09 |
10 | while true do |
11 | script.Parent.BrickColor = BrickColor.new( 255 , 0 , 0 ) |
12 | Kill() |
13 | wait(math.random( 3 , 7 )) |
14 | script.Parent.BrickColor = BrickColor.new( 255 , 255 , 255 ) |
15 | wait(math.random( 3 , 7 )) |
16 | end |
Can anybody help with this simple question
Paste this script in a script in the part.
01 | local killing = false |
02 | script.Parent.Touched:connect( function (hit) |
03 | if killing then |
04 | hit.Parent:FindFirstChild( "Humanoid" ).Health = hit.Parent:FindFirstChild( "Humanoid" ).Health - 1 |
05 | end |
06 | end ) |
07 |
08 | while true do |
09 | script.Parent.BrickColor = BrickColor.new( 255 , 0 , 0 ) |
10 | killing = true |
11 | wait(math.random( 3 , 7 )) |
12 | script.Parent.BrickColor = BrickColor.new( 255 , 255 , 255 ) |
13 | killing = false |
14 | wait(math.random( 3 , 7 )) |
15 | end |
This kills when it's red doesn't kill when it's white
Use this because you are not supplying a parameter at line 12 just check in the if statement if you are meant to kill the player use this.
01 | killing = true -- Should the part kill |
02 | function Kill(part) --probably has to do with parameter |
03 | local hum = part.Parent:FindFirstChild( "Humanoid" ) |
04 | if hum ~ = nil and killing = = true then |
05 | hum.Health = 0 |
06 | end |
07 | end |
08 |
09 | script.Parent.Touched:Connect(Kill) |
10 |
11 | while true do |
12 | script.Parent.BrickColor = BrickColor.new( 255 , 0 , 0 ) |
13 | killing = true |
14 | wait(math.random( 3 , 7 )) |
15 | script.Parent.BrickColor = BrickColor.new( 255 , 255 , 255 ) |
16 | killing = false |
17 | wait(math.random( 3 , 7 )) |
18 | end |