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

My ScreenGui won't pop up when clicked...Help!?

Here is the problem... I created a local script and made this line of script

function OnClicked() Instance.new("ScreenGui", game.StarterGui) game.StarterGui.ScreenGui.Name = "NobGui"

end

script.Parent.ClickDetector.MouseClick:connect(OnClicked)

When you click the "doorbell" a gui is supposed to pop up on the screen saying "Seems like no one is home." I'm just getting the basics of inserting a gui when the players clicks the button. I tried it and some reason it wont work!

Help!

1 answer

✓ Accepted answer
script.Parent.ClickDetector.MouseClick:Connect(function(player)
    local screengui=Instance.new'ScreenGui'
    screengui.Name='NobGui'
    screengui.Parent=player.PlayerGui
    local textlabel=Instance.new'TextLabel'
    textlabel.Text='Seems like no one is home.'
	textlabel.Size=UDim2.new(.4,0,.1,0)
	textlabel.Position=UDim2.new(.3,0,.45,0)
    textlabel.Parent=screengui
    game:GetService'Debris':AddItem(screengui,5)--removes the ScreenGui after 5 seconds
end)

A Script (not a LocalScript) inside a Part with a ClickDetector.

9 comments

0

Thank you, but it seems to have an error - Workspace.Doorbell.Bell.Script:1: attempt to call field 'MouseClick' (a userdata value)

0

Do you have a ClickDetector object in Bell?

0

I changed the code a bit try it now it must work. If it doesn't that means either the script isn't in a part or there isn't a ClickDetector in the part.

0

There is a click detector in the part

0

Thank you it works now!

0

np

0

I'd like to add something - When you inserted the gui, you inserted it into the StarterGui. If a player is clicking a part, chances are the PlayerGui is already loaded. The player would have to reset to see the gui inside StarterGui. To insert a gui so that a player can see it, your script has to find the player that clicked it (like the answer does above) and insert it into their PlayerGui.

0

It does that in line 4 which is: screengui.Parent=player.PlayerGui

0

I was referring to his line of code, where he used:Instance.new("ScreenGui", game.StarterGui)

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