Heya, I need help with the script, I’m trying to script a part that, after touching, Brickcolor changes, I tried to find it on ytb, but it didn’t move, you don’t know what’s wrong with it?
local cervena1 = game.Workspace.d1
local cervena2 = game.Workspace.d3
local con = script.Parent
local function onTouch()
cervena1.BrickColor = BrickColor.new(76, 255, 62)
wait(3)
cervena1.BrickColor = BrickColor.new(250, 0, 0)
end
cervena1.Touched:Connect(onTouch)
local cervena1 = game.Workspace.d1
local cervena2 = game.Workspace.d3
local con = script.Parent
local debounce = false
local function onTouch()
if not debounce then
debounce = true
cervena1.Color = Color3.fromRGB(76, 255, 62)
task.wait(3)
cervena1.Color = Color3.fromRGB(250, 0, 0)
debounce = false
end
end
cervena1.Touched:Connect(onTouch)
Is this a LocalScript or a server script? Your script works perfectly fine when I use it, so my presumption is that you’re using a LocalScript in workspace (localscripts don’t run in workspace unless parented to a player’s character)
You are putting numbers in BrickColor.new() like Color3.fromRGB() you’re supposed to put the BrickColor name not a Color3, like BrickColor.new("Bright blue")
try doing this:
local cervena1 = game.Workspace.d1
local cervena2 = game.Workspace.d3
local con = script.Parent
local function onTouch()
cervena1.Color = Color3.fromRGB(76, 255, 62)
wait(3)
cervena1.Color = Color3.fromRGB(250, 0, 0)
end
cervena1.Touched:Connect(onTouch)
You sure ur using the right part? try using this code
local colorChangePart = script.Parent
local debounce = false
local function onTouch()
if not debounce then
debounce = true
colorChangePart.Color = Color3.fromRGB(76, 255, 62)
task.wait(3)
colorChangePart.Color = Color3.fromRGB(250, 0, 0)
debounce = false
end
end
colorChangePart.Touched:Connect(onTouch)
local cervena1 = game.Workspace.d1
local cervena2 = game.Workspace.d3
local con = script.Parent
local function onTouch()
cervena1.Color = Color3.fromRGB(76, 255, 62)
task.wait(3)
cervena1.Color = Color3.fromRGB(250, 0, 0)
end
cervena1.Touched:Connect(onTouch)
The problem was you were changing the BrickColor using an RGB component. More details can be found here: Color3 | BrickColor
I do notice you were having problems changing some things local, would you elaborate?