Im creating script that will lock server so no-one can join it.
But it throws an error: locked is not a valid member of Folder “ServerStorage.Settings”
So i added print statement:
cfg = game.ServerStorage.Settings
for i, value in cfg:GetChildren() do
print(i, ": ", value)
end
And it outputs:
14:27:11.959 1 : ps - Server - handleEvent:12
14:27:11.962 2 : locked - Server - handleEvent:12
14:27:11.962 3 : version - Server - handleEvent:12
Also, to mention it worked before in other script where i used commands instead of gui, when i deleted and put it into gui it stopped working and after i got it back to commands it still didnt work
Didnt work either, but it would change nothing because it was already getting instance and not throwing error about Settings is nil (output is still same)
By roblox autocomplete i mean that it gives me ‘locked’ as child of Settings meaning im not blind idiot and it actually exists (like if i created function it will showup in this gui to help me and so i could tab to auto-complete it)
I dont know difference between game.child and game:GetService(), i mean one is method but both still return instance?
Even if it works in auto complete it’s still good to ENSURE it exists.
I’ve done some quick testing and gotten it to work:
Script:
local ServerStorage = game:GetService("ServerStorage")
local Settings = ServerStorage:WaitForChild("Settings")
for i, v in Settings:GetChildren() do
if v:IsA("IntValue") then
print(v.Value)
v.Value = 2
print(v.Value)
elseif v:IsA("StringValue") then
print(v.Value)
v.Value = "wassup"
print(v.Value)
end
end
Is this something along the lines of what you want your script to do?
Edit: 5 and hello are the default values I set. 2 and wassup are the ones set in the script.
cfg = game:GetService("ServerStorage").Settings
for i, child in cfg:GetChildren() do
print(i, ": ", child)
if child:IsA("BoolValue") then
child.Value = true
print(i, ": ", child, ", ", child.Value)
end
end
It exists for 100%, even kicks me when i join cuz locked is true lol:
Server Kick Message: This server is locked.
LMAO and interesting that:
if cfg.locked.Value == true and plr.UserId ~= ownerId then
plr:Kick("This server is locked.")
end
That’s the same place the script used in my example was located so it should definitely work. If it exists then as I mentioned earlier try adding .Value to the end of cfg.locked.
Edit: This is a common mistake that I myself still do sometimes. Always remember to add .Value if you’re going to modify the Value property in value instances!
The most confusing that i hate rioblox engine throws error ‘invalid member’ cuz for me it seems like ‘locked’ instance doesnt exists but instead it tries to find property of folder