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

Value does not exist?

The value returns a nil value, even though it is there.

The script is in a model in a workspace

Model -Script -ServerLock (Variable already set to true) -off (Button to modify the variable when clicked) -on (Button to modify the variable when clicked)

The variable is there because it should be able to be adjusted in game.

local Admins = {'Builderman','KZskychi'}

local BanMessage = 'There is currently no flight on at present time or the server has been locked by an admin. Please check the group shout for flight times.'


game.Players.PlayerAdded:connect(function(player)
	for i = 1, #Admins do
		if script.Parent.ServerLock.Value == true then
			if player.Name == Admins[i] then
			
			else
				player:Destroy()
				player:Kick(BanMessage)
		end
		end
		end
end)

2 answers

Although I've not actually tested this by the looks of it the error is on line 8 if script.Parent.ServerLock.Value == true then


You're only selecting the property called Value rather than what the value actually is within that property.

To fix this you'd want to change it to

if script.Parent.ServerLock.Value.Value == true then


If this answered your question accept my answer with the button on the right, if it doesn't work please tell me and if you'd like a better explanation please let me know!

3 comments

0

This error came up: attempt to index field 'Value' (a Boolean value)

0

What is the ServerLock instance in workspace? IntValue, StringValue, BoolValue???

0

BoolValue

Changed it to a string value and it now works, not gonna use BoolValue again

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