I have this very long script, it works kind of, but I want to learn how to detect the color without a touch event. Anyone that know how to do that?
This script should detect a certain color and then all the other parts that has other colors should disappear.
local platform = script.Parent
platform.Transparency = 1
while true do
local randomValue = math.random(1, 7)
print(randomValue)
if randomValue == 1 then
print("Purple")
elseif randomValue == 2 then
print("Pink")
elseif randomValue == 3 then
print("White")
elseif randomValue == 4 then
print("Yellow")
elseif randomValue == 5 then
print("Green")
elseif randomValue == 6 then
print("Blue")
elseif randomValue == 7 then
print("Red")
end
wait(5)
platform.Touched:Connect(function(hit)
print(hit)
if randomValue == 1 then
if hit.BrickColor.Name == "Terra Cotta" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Electric blue" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Moss" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Daisy orange" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Pearl" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Sunrise" then
hit.Transparency = 1
hit.CanCollide = true
--elseif hit.BrickColor.Name == "Lilac" then
--hit.Transparency = 1
--hit.CanCollide = true
end
end
if randomValue == 2 then
if hit.BrickColor.Name == "Terra Cotta" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Electric blue" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Moss" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Daisy orange" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Pearl" then
hit.Transparency = 1
hit.CanCollide = true
--elseif hit.BrickColor.Name == "Sunrise" then
--hit.Transparency = 1
--hit.CanCollide = true
elseif hit.BrickColor.Name == "Lilac" then
hit.Transparency = 1
hit.CanCollide = true
end
end
if randomValue == 3 then
if hit.BrickColor.Name == "Terra Cotta" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Electric blue" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Moss" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Daisy orange" then
hit.Transparency = 1
hit.CanCollide = true
--elseif hit.BrickColor.Name == "Pearl" then
--hit.Transparency = 1
--hit.CanCollide = true
elseif hit.BrickColor.Name == "Sunrise" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Lilac" then
hit.Transparency = 1
hit.CanCollide = true
end
end
if randomValue == 4 then
if hit.BrickColor.Name == "Terra Cotta" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Electric blue" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Moss" then
hit.Transparency = 1
hit.CanCollide = true
--elseif hit.BrickColor.Name == "Daisy orange" then
-- hit.Transparency = 1
--hit.CanCollide = true
elseif hit.BrickColor.Name == "Pearl" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Sunrise" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Lilac" then
hit.Transparency = 1
hit.CanCollide = true
end
end
if randomValue == 5 then
if hit.BrickColor.Name == "Terra Cotta" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Electric blue" then
hit.Transparency = 1
hit.CanCollide = true
--elseif hit.BrickColor.Name == "Moss" then
-- hit.Transparency = 1
-- hit.CanCollide = true
elseif hit.BrickColor.Name == "Daisy orange" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Pearl" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Sunrise" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Lilac" then
hit.Transparency = 1
hit.CanCollide = true
end
end
if randomValue == 6 then
if hit.BrickColor.Name == "Terra Cotta" then
hit.Transparency = 1
hit.CanCollide = true
--elseif hit.BrickColor.Name == "Electric blue" then
-- hit.Transparency = 1
--hit.CanCollide = true
elseif hit.BrickColor.Name == "Moss" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Daisy orange" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Pearl" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Sunrise" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Lilac" then
hit.Transparency = 1
hit.CanCollide = true
end
end
if randomValue == 7 then
--if hit.BrickColor.Name == "Terra Cotta" then
--hit.Transparency = 1
--hit.CanCollide = true
if hit.BrickColor.Name == "Electric blue" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Moss" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Daisy orange" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Pearl" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Sunrise" then
hit.Transparency = 1
hit.CanCollide = true
elseif hit.BrickColor.Name == "Lilac" then
hit.Transparency = 1
hit.CanCollide = true
end
end
wait(5)
hit.Transparency = 0
hit.CanCollide = false
end)
end
Thanks, Xsodar

1 comment
All parts in a model to be clear