How come whenever I want to make it to where when I click on the specific block, it doesn't change the variable 'PERMISSION' to true? The only thing i'm needing it to do is change that variable inside of a function.
Thank you for your time
PERMISSION = false script.Parent.ClickDetector.MouseClick:Connect(function(PERMISSIONGRANTED) script.Parent.BrickColor = BrickColor.new ("Lime green") PERMISSION = true end) if PERMISSION == true then print("SCRIPT SUCCESSFUL") end
It does change the variable to true. The reason it doesn't print "SCRIPT SUCCESSFUL"
is because you only check if the value is true once.
You can just put the print and the rest of the code after line 6, (after setting PERMISSION
to true
). That way you won't have to check if it's true, but rather do stuff straight away.
Btw, a little tip: use local variables.
local PERMISSION = false script.Parent.ClickDetector.MouseClick:Connect(function(PERMISSIONGRANTED) script.Parent.BrickColor = BrickColor.new ("Lime green") PERMISSION = true print("SCRIPT SUCCESSFUL") --stuff end)