Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

[[Solved]] Why does this ObjectValue's Value remain nil on online mode?

Asked by
coo1o 227 Moderation Voter
10 years ago

Solved by Merely. Thanks!

Ok, so I made a script that works when a player joins the game. It works perfectly in Solo but in online mode (As in servers and online and such), the ObjectValue by the name of "load_function"'s Value property remains nil.

Here's the (server) script; I added comments to try to add description into the code for you:

local w = function(p,o) return p:WaitForChild(o) end --Just waits for a child
local load_map = w(script,"load_map") --This is a RemoteEvent. This is what the ObjectValue's Value is set to

players.PlayerAdded:connect(function(p)
    print("weeeee") --Just tells me if the event fires

    local nls = ls:Clone() --This just an other local script, ignore this
    nls.Parent = w(p,"PlayerGui") --And this...

    --The problems begin here

    local main = menuGUI:Clone() --A ScreenGui containing another local script there we'll be looking at
    main.Parent = w(p,"PlayerGui")  --Adds the Gui to the PlayerGui
    w(main,"load_function").Value = load_map --[[Here, I set the RemoteFunction as the value for the ObjectValue "load_function"
For some reason, Value IS set to the RemoteFunction in Solo Mode, but in online mode it is nil...
]]
    w(main,"script").Disabled = false --Here, I enable the local script that uses the ObjectValue
end)

If you actually help or even bother to try and help, I thank you.

~coo1o

0
Try getting rid of the local before the w variable maybe? Not too sure. Also, I'm assume you've already created a players variable for line 4, correct? Spongocardo 1991 — 10y
1
Is this script in ServerStorage? If so, the load_function object won't replicate. Merely 2122 — 10y
0
Oh yeah, the script is in ServerScriptService but the principles are the same for both. Thanks, Merely! coo1o 227 — 10y

Answer this question