Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why isn't my variable 'PERMISSION' changing when the function is activated?

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

2 comments

0

please use code blocks

0

If kiriot22 solves your problem don't forget to accept his answer

1 answer

✓ Accepted answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.