Buy coins UI not visible

I tried to write a script where if the TextButton is pressed it opens this Frame:


But it does not seem to open the text button is this:
image
there is a script inside that:
image
This is the script

local frame = game.StarterGui.BuyCoinsUI.BuyCoins
script.Parent.MouseButton1Click:Connect(function()
	frame.Visible = true
end)
2 Likes

Try this:

local frame = script.Parent.BuyCoins
script.Parent.MouseButton1Click:Connect(function()
    frame.Visible = true
    script.Parent.Visible = false
end)
1 Like

To @superkingburger1456 :
Do not use game.StarterGui. Instead use this, if your using a local script use script.Parent or game.Players.LocalPlayer. In script use script.Parent because you can’t find the local player in normal script.

To @kry1068 :
You don’t have to use script.Parent.Visible = false because i can see that its like this.


So it will not be able to open again if its invisible

EDIT: correcting my incorrect

2 Likes

Yea my first idea was that itself but If I do script.Parent then it will approach the screen GUI not the frame so I did this.

1 Like

Nope I tried that but this is the result.

1 Like

Try that:

local Player = game.Players.LocalPlayer
local PlayerGui = Player.PlayerGui
local Frame = PlayerGui.BuyCoinsUI.BuyCoins
local Button = PlayerGui.BuyCoinsUI.TextButton
Button:MouseButton1Click:Connect(function()
frame.Visible = true
end)
1 Like

It should be local frame = script.Parent.Parent.BuyCoins, you forgot a parent

2 Likes

So this is the more complex one but it works

Could you please me explain me the script if you don’t mind?

1 Like

Well thank you @Boele009 but @PhantomGame_Youtube gave the solution

Okay sure, do you need it still?

1 Like

I want you to explain the script but it works by the way

1 Like

A second…
Try that:

local Player = game.Players.LocalPlayer -- Getting one player
local PlayerGui = Player.PlayerGui -- Accessing that Player PlayerGui(Like screenGui, but if you use local script you need to access PlayerGui)
local Frame = PlayerGui.BuyCoinsUI.BuyCoins -- Getting your frame in screen of that player
local Button = PlayerGui.BuyCoinsUI.TextButton -- Declaring your button which need to click in screen of that player
Button:MouseButton1Click:Connect(function() -- Connecting function when player click button
frame.Visible = true -- frame become visible
end) -- ends script

If you don’t understand smth of lines contact me, i will afk for a bit

I am here, contact me if there is problems

Nope no doubts, I do have some scripting knowledge but I get very frustrated with these opening UI scripts. Some work some don’t

But anyways thanks @PhantomGame_Youtube , @Boele009 @kry1068 @InvalidRaycast for the help too

1 Like

I have a small solution to you:
I suggest you to look AlvinBlox scripting tutorials(I learned by them), he explain everything very good
Link to first video:How To Script On Roblox 2021 - Episode 1 (Properties) - YouTube

Hey, Thanks man I have seen some tutorials and practiced them in roblox studio by Alvin Blox. He explains the scripts way better than any other youtubers. Thanks I never knew e had something like this. Appreciate it @PhantomGame_Youtube

1 Like

No problem, good luck scripting your game, also i very interested what game are you making, if it is public, could you give me link i just wanna check it xD

I’m sorry but I am still developing it as you in the screenshot I was making a Desert map. It is a simulator map by the way. Thanks, Good luck for your career too, Bye

1 Like

Okay, thanks you too, Bye and good luck!

1 Like