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
Here is the answer!
while true do script.Parent.BrickColor = BrickColor.new(Color3.new(255, 255, 255)) wait(5) script.Parent.BrickColor = BrickColor.new(Color3.new(255, 0, 0)) function onTouch(part) if script.Parent.BrickColor == BrickColor.new(Color3.new(255, 0, 0)) then local humanoid = part.Parent:FindFirstChild("Humanoid") if humanoid ~= nil then humanoid.Health = 0 end else wait() end end script.Parent.Touched:Connect(onTouch) wait(3) end
Something that may be useful to know: when using Color3.new, the highest value that goes in the ()'s is 1 (it won't error if you go above 1), using Color3.fromRGB is where using the integers between 0 and 255 apply. OT: TinyScripter's script is most likely the fix.