So, I was trying out if statements(nothing too long) and something didn't work. Please help, It's the first script I make that doesn't work at all :(
if game.Workspace.Part.Transparency == 0 then print"It is not transparent" elseif game.Workspace.Part.Transparency == 0.5 then print"It is transparent" elseif game.Workspace.Part.Transparency == 0.6 then print"It is slightly more transparent" end
When I make the transparency of the part 0.5, it prints "it is transparent" into the Output. However, when I make the transparency of the part 0.6, the system doesn't print "it is slightly more transparent" into the Output. I'm not sure if there's something wrong with my indenting, but I would appreciate it if someone helped me with this predicament.?
I fixed the problem by changing the second elseif to:
elseif Game.Workspace.Part.Transparency > 0.5 then print("it is slightly more transparent")
When I did this, the system printed "it is slightly more transparent" but I want to know why it wasn't working the first time.?
Well, you need to trigger when to run that line of code. You could put it in a loop, but that would simply spam your Output. I recommend using the Changed event to resolve your issue.
Part = game.Workspace.Part Part.Changed:connect(function() if game.Workspace.Part.Transparency == 0 then print"It is not transparent" elseif game.Workspace.Part.Transparency == 0.5 then print"It is transparent" elseif game.Workspace.Part.Transparency == 0.6 then print"It is slightly more transparent" end end)