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

Why is the gui's children deleting when doing into Playergui?

Asked by 8 years ago

I'm doing a check to see if someone has a shirt, and if they do clone a gui into the players gui.

but whenever I move it, it deletes the children..

Code

local Player = game.Players.LocalPlayer
local Items = {291002383,291002527,291002685,291003057,291004569,342437379}

local Owns = function()
    for i = 1, #Items do
        if game:GetService("MarketplaceService"):PlayerOwnsAsset(Player, tonumber(Items[i])) then
                local gui = script.Guis.gui
                local CGui = gui:Clone()
                CGui.Parent = Player.PlayerGui
                print(CGui.Parent)
            return true
        end
    end
    return false
end

11:28:07.711 - Something unexpectedly tried to set the parent of gui to NULL while trying to set the parent of gui. Current parent is PlayerGui.

Help? If you need more of an explanation, please post a comment

1 answer

Log in to vote
1
Answered by 8 years ago

Replication

Roblox doesn't really like the LocalScripts trying to do stuff that it can't see. One of these issues is trying to parent new Instances from a LocalScript whilst replication is trying to work its way across the server. Result? Chaos.

You should try and wait a bit before moving the stuff into PlayerGui, so that it doesn't flip out. We had a similar problem when working with Valkyrie, so you're not alone. If FE isn't on, I would recommend using it, as it solves a lot of other issues and vulnerabilities when done properly, as well as encouraging good standards.

0
Using a module script. ;) DeveloperSolo 370 — 8y
0
It doesn't matter. A ModuleScript inherits the <environment> (used loosely) it's used from, and if that's a LocalScript then the ModuleScript is treated as a LocalScript. User#6546 35 — 8y
0
How long should I wait then? DeveloperSolo 370 — 8y
0
Not actually sure. c: User#6546 35 — 8y
View all comments (4 more)
0
Our end solution for Valkyrie was to not move it to PlayerGui at all. We ended up with a weird solution for it. User#6546 35 — 8y
0
Well, I need it in that on persons gui. What was the weird solution? DeveloperSolo 370 — 8y
0
Not one that will work here. Where is script? User#6546 35 — 8y
0
Well, the module script can't be moved or other scripts will break. I'll find another way. Weird that other guis work just fine moving but ok DeveloperSolo 370 — 8y
Ad

Answer this question