I'm making a script that kills the player ONLY when the color is red. When it is white, I don't want it to kill the player.
Here is what I have so far, it changes the color from white to red, but kills the player no matter which color it is:
while true do
script.Parent.BrickColor = BrickColor.new(Color3.new(255, 255, 255))
wait(3)
script.Parent.BrickColor = BrickColor.new(Color3.new(255, 0, 0))
function onTouch(part)
local humanoid = part.Parent:FindFirstChild("Humanoid")
if (humanoid ~= nil) then -- if a humanoid exists, then
humanoid.Health = 0 -- damage the humanoid
end
end
script.Parent.Touched:connect(onTouch)
wait(3)
end

2 comments
Yep I found your problem. (humanoid ~= nil) should be humanoid ~= nil
And some other things, too.