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

Can't access frame that is in playergui returned through remote function?

Asked by 6 years ago

I have the remote function:

local event = game.ReplicatedStorage.Work.genhud

local function genHUD()
    local jobHUD = game.ReplicatedStorage.jobHUD
    local hud = jobHUD:Clone()
    hud.Parent = player.PlayerGui.mainHUD
    return hud
end

event.OnClientInvoke = genHUD

But whenever I call it in a server script, it says that hud is nil for some reason?

local event = game.ReplicatedStorage.Work.genhud

script.MouseButton1Click:Connect(function()

local hud = event:InvokeClient(player)
print(hud)

end)

Should I add that this event works perfectly in studio, it just doesn't work in game.

0
the reason why it's printing nil is because the server can't see a player's gui, rather once it is cloned and you know it's cloned there's no reason to return any value LukeGabrieI 73 — 6y

1 answer

Log in to vote
1
Answered by 6 years ago
Edited 6 years ago

You can't pass instances through a RemoteEvent or RemoteFunction. You can only pass more primitive datatypes like...

Numbers, Strings, Booleans, Tables, Vectors...

The Wiki says it at the bottom of this page: https://wiki.roblox.com/index.php?title=Remote_Functions_%26_Events

Ad

Answer this question