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

ScreenGUI not visible after being cloned?

Asked by 2 years ago

Hey! I am having trouble with my ScreenGUI not being visible after it is Cloned from ReplicatedStorage, I would like the GUI to be visible when the player is sitting down but for it to be deleted when the player stands up. Here is my code:

local Seat = game.Workspace.Nexus.Nexus:WaitForChild("Seat")

local player = game.Players.LocalPlayer

local gui = game.ReplicatedStorage.ScreenGui

local character = player.CharacterAdded:Wait()

local hum = character:WaitForChild("Humanoid")

hum.Seated:Connect(function(hit)
    print("Player detected on "..Seat.Parent.Name)
    local newGui = gui:Clone()
    newGui.Parent = game.StarterGui
    newGui.Frame.Active = true
    repeat wait() until not player.Character.Humanoid.Sit
    print("Player no longer detected on "..Seat.Parent.Name)
    wait(0.1)
    newGui:Destroy()
end)


And here is what happens:

https://imgur.com/a/akyBbob

Thanks!

1 answer

Log in to vote
0
Answered by 2 years ago
newGui.Parent = player.PlayerGui

StarterGui only serves to copy whatever's in there into the PlayerGui every time the player respawns, so if you wanna have things show up to the player's immediate gui try parenting to the player's PlayerGui instead

Ad

Answer this question