literally just started scripting, very basic, pls help
output is always "it's not" even though the transparency of the parent IS 0
yeet = game.Workspace.Part function onClicked () if script.Parent.Transparency == '0' then script.Parent.Properties.BrickColor = 'Really red' else print("it's not") end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
When addressing things like Transparency, you don't actually need to address the "properties."
You did:
script.Parent.Properties.BrickColor = 'Really red'
When you should do
script.Parent.BrickColor = 'Really red'
But, you forgot one thing.
local yeet = game.Workspace.Part --don't forget the local! function onClicked () if script.Parent.Transparency == '0' then script.Parent.Properties.BrickColor = BrickColor.new('Really red') --You need to add the "BrickColor.new()" else warn("it's not") --Tip: You can change the print to "Warn", and it will appear yellow in the output. Nothing important, just easier to read. end end script.Parent.ClickDetector.MouseClick:connect(onClicked)
You forgot the BrickColor.new()
If this helped, then please accept the answer. Thanks!
Glad you've taken an interest in scripting! You're very close to solving this problem. Transparency accepts a float value, which is essentially a number. When you were attempting to compare it against a string, it would always return false since a number isn't a string. To fix that problem, you need to remove the quotes, and it'll become a number! I also noticed another problem. When you were attempting to change the BrickColor, you do not need to state 'Properties'. Think of it like Transparency, you can directly go to it. When setting a BrickColor of a part, it takes a BrickColor value, and in this case you can use BrickColor.new(). So:
yeet = game.Workspace.Part function onClicked () if script.Parent.Transparency == 0 then script.Parent.BrickColor = BrickColor.new('Really red') else print("it's not") end end script.Parent.ClickDetector.MouseClick:Connect(onClicked) -- Tiny edit here! 'connect' is deprecated (no longer supported), so be sure to use 'Connect'!