Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why doesn't the Gui show up on thescreen?





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

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.

1 comment

0

Thank you so much

This discussion is preserved as it was. New answers, comments, and votes are closed.