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

How do I fix this Variable? It keeps saying nil.

I've been trying to make a restricted door using this:

playerAllow = ("player:IsInGroup(2910772)")

local door = script.Parent
 
function open()
	door.CanCollide = false
 
	for transparency = 0, 1, .1 do
		door.Transparency = transparency
		wait(.1)
	end
end
 
function close()
	for transparency = 1, 0, -.1 do
		door.Transparency = transparency
		wait(.1)
	end
	door.CanCollide = true
end

local allow(playerAllow) --Error

	if allow then
		open()
		delay(4, close)
	end
end)

I tried changing the player:IsInGroup(2910772) because before I tried it and it wouldn't agree because this part:

local allow(player:IsInGroup(2910772)) --Error

	if allow then
		open()
		delay(4, close)
	end
end)

And if I did this:

local allow(player:IsInGroup(2910772)

	if <--Error-- allow then -- then say )' Expected to close something about that.
		open()
		delay(4, close)
	end
end)

But now, I think I'm doing it wrong or something... because it now says

local allow(playerAllow) --Error, must be a Variable or field.

I thought I changed it into a variable. when I used

playerAllow = ("player:IsInGroup(2910772)")

I just figured out how to use scripts today and have looked at all the tutorials including variables. However none helped. Also. When I use the command bar for: print(playerAllow) it comes up as:

print(playerAllow) nil instead of: playerAllow = player:IsInGroup(2910772) Like it should, right? Again, I'm still a noob >._. Plz help.

3 comments

0

Or maybe I just did something wrong with the door? Idk. Still plz help.

0

Quoting your code will make it a string

1

Edited to fix formatting. Make your questions readable!!

1 answer

Even though your question is quite confusing, I will try anyways:

playerAllow = (player:IsInGroup(2910772)) --Changing the playerAllow from a string to turn it into a boolvalue
if playerAllow == true then --Checking if the boolvalue is true
	open() --Everything here is just like you had it
	delay(4, close)
end

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