x = game.workspace.Part function onClicked(z) x.Transparency = 1 x.CanCollide = false x.BrickColor = BrickColor.new("Really green") wait (5) x.Transparency = 0 x.CanCollide = true x.BrickColor = BrickColor.new("Really red") end game.Workspace.ClickDetector.MouseClick:connect(onClicked)
I added a clickdetector into the part as well but when I click it the Part doesnt change at all
The problem is that the ClickDetector you are connecting the function to is not in the part. You need to put it in the part, then change the script accordingly:
local part = script.Parent -- This assumes the script is inside the part. function onClicked() part.Transparency = 1 part.CanCollide = false part.BrickColor = BrickColor.new("Really green") wait (5) part.Transparency = 0 part.CanCollide = true part.BrickColor = BrickColor.new("Really red") end part.ClickDetector.MouseClick:connect(onClicked)
Also, I would recommend using more descriptive variable names. It will make the script easier to understand.