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

Why won't it Clone() to PlayerGui?

Asked by
TofuBytes 500 Moderation Voter
10 years ago

I'm lost on how I clone a GUI from ReplicatedStorage into the PlayerGui which is moved to Team "Special Players". I've been testing, but I couldn't find the reason. Any help?

local special = game.Teams:findFirstChild("Special Players")

function onEntered(player)
    if checkOkToLetIn(player.Name) then
        player.TeamColor = special.TeamColor
        game.ReplicatedStorage.GreetingScreen:Clone().Parent = player.PlayerGui
    end
end

1 answer

Log in to vote
1
Answered by
HexC3D 830 Moderation Voter
10 years ago
local special = game.Teams:findFirstChild("Special Players")

game.Players.PlayerAdded:connect(function(player)
    if checkOkToLetIn(player.Name) then
        player.TeamColor = special.TeamColor
        game.ReplicatedStorage.GreetingScreen:Clone().Parent = player:WaitForDataReady("PlayerGui")
    end
end)

This should work, you should use WaitForDataReady() Because you don't want the script load before the PlayerGui exists.

Ad

Answer this question