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

Why is my ScreenGui not appearing In-Game?

I've made a few ScreenGui"s" and when you click on something the Gui will appear and it works in the studio but not In-Game

Here is my script :

local function click (player)
	player.PlayerGui.ScreenGui.Frame.Visible = true
end

script.Parent.ClickDetector.mouseClick:connect(click)

Is there anything wrong with the script that makes it not appear in the game?

I'd be pleased if someone tells me what's wrong with the script.

I'll thank you in advance if you tell me.

2 answers

✓ Accepted answer
local Button = script.Parent
Frame = script.Parent.Parent.Frame

function onClick()
if Frame.Visible == false then
Frame.Visible = true
elseif Frame.Visible == true then
Frame.Visible = false
end
end

Button.MouseButton1Click:connect(onClick)

This is a code where you Open/Close the Frame you want, if you want just to open it when you click, delete lines 7-9. However, if you want just to close it delete lines 5-6 and one of the end's at the end. Make sure this script is into a textButton, which textButton is into the frame you're want to close/open. Accept this answer if this worked please, to help me.

1 comment

0

I gave you a code but I didn't see the question, xD. So, if your script is into something related to GUI's you have to use MouseButton1Click instead of ClickDetector cause this is for Parts. Also, you shouldn't use local funtion, just funtion. Last but not least, line 2 is completely wrong since you HAVE TO use script.Parent... if your script is into the GUI you're trying to code for.

###Lots wrong with your code.

##Problem 1: You’re using mouseClick, which is deprecated ##Solution 1: Use MouseClick

##Problem 2: You’re modifying a GuiObject on the server ##Solution 2: Fire a RemoteEvent to the client (FE compatible as bonus!)

##Problem 3: On line 1, there is a space between click (player) ##Solution 3: Remove it, so it says click(player)

###Another thing to note, switch to Connect, as ROBLOX has plans to remove connect.

1 comment

0

Problem 1: that's correct, Problem 2: Scripting is about trying to make things work with least amount of work. You can modify a GuiObject from server side just fine. Problem 3: That's just your formatting prefrence, it has nothing to do with problems that he/she is facing.

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