So the problem is that the ObjectValue his Value is nil. I know why it's being set to nil I just don't know how to fix it.
So I got a ServerScript requiring a ModuleScript. Now the thing is I don't want people to steal my ModuleScripts code.
ModuleScript that is being required:
------- PREVENT STEALING:
local MS = Instance.new("ModuleScript")
script.Parent = MS
Now inside the ModuleScript(the ModuleScript that's required) I have a ServerScript. And in the ServerScript is a Folder called GUIS. With all my ScreenGui's.
ServerScript:
local Player = game:GetService("Players").LocalPlayer
local GUIS = script:WaitForChild("GUIS")
function InsertGui(Plr, String)
local PlrGui = Plr:FindFirstChild("PlayerGui")
if PlrGui and GUIS:FindFirstChild(String) then
for i, v in pairs(PlrGui:GetChildren()) do
if v.Name == String then
v:Destroy()
end
end
local Gui = GUIS[String]:Clone()
local OV = Instance.new("ObjectValue")
OV.Name = "OV"
OV.Value = script -- Inside the LocalScript this becomes nil.
OV.Parent = Gui
Gui.Parent = PlrGui
end
end
InsertGui(Player, "CmdsGui") -- And "YES" the CmdsGui is in the Folder.(In-case you're asking.)
Now there is a LocalScript inside the CmdsGui.
The error happens in the LocalScript.
LocalScript which is inside the CmdsGui:
local Gui = script.Parent
local OV = Gui:WaitForChild("OV").Value -- Becomes nil.
-- Ok, so now OV's Value is nil...
-- It's because I set the required ModuleScript's Parent to something that is nil.
-- If I don't do that it works fine, but I don't want my code to be stolen...
Important notes: My game is FilteringEnabled.
So... how to fix this? I already tried to solve this with RemoteFunctions still "nil". Please tell me if you need more information. You're a hero if you solve this ;). Thank you for your time.

2 comments
Mhhh... I think I got a way to fix this. Do you know how to check if you'r game is in Online Mode? Since I can make it so the Scripts removes itself if the game doesn't run in Online Mode.
Eh, that won't help. If they can run it in studio, they can also just remove the code that checks for online mode. But if you really want to know, check the wiki page for "RunService", it has some methods that could help.