I am new to scripting, so I am not too sure where I am going wrong. I have a separate script that changes the color of the brick every 1 second, and I want the brick to kill the player if the color lands on blue. This is the script I have:
local brick = script.Parent
function kill(part)
if brick.BrickColor == Color3.new(0,0,1) then
local h = part.Parent:FindFirstChild("Humanoid")
if h then
if h.Health > 0 then
h.Health = 0
end
end
end
end
script.Parent.Touched:Connect(function(kill)
end)
The script kills the player when I remove the color part, but I want it to kill the player ONLY if the brick is blue. Can someone tell me where I am going wrong, please?

3 comments
Please properly indent your code. Also do not use deprecated methods like :connect. Also there is not a problem with setting the humanoid's health to 0.
@Phlegethon, thanks for reminding me about that, also I didn't say there is a problem with setting humanoid health, I'm just saying I feel it would be easier to do BreakJoints
Thanks for the help, I now have my script working. I agree that BreakJoints is easier and I now use that! Thank you :)