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

Why doesn't the Gui show up on thescreen?

Asked by 8 years ago




script.Parent.Touched:connect(function() local enabled = true local screengui = Instance.new("ScreenGui") screengui.Parent = game.StarterGui --For earned------- wait(4) local Earned = Instance.new("ImageLabel") Earned.Parent = screengui Earned.Position = UDim2.new(0.4,0,0.2,0) Earned.Size = UDim2.new(0,250,0,250) Earned.Image = "http://www.roblox.com/asset/?id=377070223" Earned.Visible = true end)

i tried it in a local script put the script wont activate or in a regualer script it won't show up on your screen.

and no errors came up in the output

1 answer

Log in to vote
0
Answered by
Pyrondon 2089 Game Jam Winner Moderation Voter Community Moderator
8 years ago

StarterGui is just a container. It's contents are copied over to the player's PlayerGui. So, parenting things to the StarterGui won't work.

script.Parent.Touched:connect(function(hit)
    if game.Players:GetPlayerFromCharacter(hit.Parent) ~= nil then -- Check if what touched it is even a player.
        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
        local enabled = true
        local screengui = Instance.new("ScreenGui")
        screengui.Parent = player.PlayerGui -- You parent it to the PlayerGui, not StarterGui.
        --For earned-------
        wait(4)
        local Earned = Instance.new("ImageLabel")
        Earned.Parent = screengui
        Earned.Position = UDim2.new(0.4,0,0.2,0)
        Earned.Size = UDim2.new(0,250,0,250)
        Earned.Image = "http://www.roblox.com/asset/?id=377070223"      
        Earned.Visible = true
    end
end)

Hope this helped.

0
Thank you so much bradleyawsome 10 — 8y
Ad

Answer this question