How to make the gui work correctly

Hello, I hope you are fine, so I want to make a frame visible when a player touches an area. but in a different way than the common one and they tell me where I should locate the script. I don’t need a script I just need you to tell me how to do it I know how to program thanks

1 Like

Well, if you want it to trigger when the player touches it I’d put it in a server script inside of the object you want the player to touch.

2 Likes

I’m sorry friend but it doesn’t work:

local zone = script.Parent
local gui = game.StarterGui.EmotesGui
local frame = gui.ShopButton
frame.Visible = false
zone.Touched:Connect(function(hit)
      if hit.Parent:FindFirtsChild("Humanoid") then

frame.Visible = true
end
end)

-Yes, the cantouch is there.
-I put a server script
-the father was the zone
-specify well the frame and tell me
what is the mistake?

Well first of all, “FindFirtsChild” is misspelled. But here is the code I would recommend:

local zone = script.Parent
local gui = game.StarterGui.EmotesGui
local frame = gui.ShopButton
frame.Visible = false
zone.Touched:Connect(function(hit)
      if hit.Parent:FindFirstChildOfClass("Humanoid") then
               frame.Visible = true
      end
end)

Go ahead and try that.

1 Like

Hello, I did it as you told me but there is no difference, there are no changes:

local zone = script.Parent
local gui = game.StarterGui.EmotesGui
local frame = gui.ShopButton
frame.Visible = false
zone.Touched:Connect(function(hit)
       if hit.Parent:FindFirstChildOfClass("Humanoid") then
                frame.Visible = true
       end
end)

I checked that the part did not move when executing but nothing.
and also in the output nothing comes out

Local plr = game.Players.LocalPlayer
Local gui = plr.PlayerGui.EmotesGui
Local frame = gui.ShopButton

Local zone = script.Parent 

zone.Touched:Connect(function(hit)
if hit.Parent:WaitForChild(“Humanoid”) then 
frame.Visible = true
end
end)

You should access gui through PlayerGui, not StarterGui.

This might not work because I’m on a mobile device.

1 Like

If something touches this that does not contain a Humanoid, that thread will hang forever and you will have a memory leak.

I did what you told me but nothing changes then I put a print right after the function and then when I executed it in the output the print came out but the function didn’t pass also I checked on the client side it didn’t work either you don’t have any other way or some property of the frame that has to be inactive or active?

--Put this Script in the Area
local Area = script.Parent

Area.Touched:Connect(function(Hit)
	if Hit.Parent:FindFirstChild("Humanoid") then
		local Player = game.Players:GetPlayerFromCharacter(Hit.Parent)
		local Frame = Player.PlayerGui.ScreenGui.Frame --Path of Frame in Player.PlayerGui
		Frame.Visible = true
	end
end)

Hello, thank you very much for the help, but you know I realized that you know a lot about Guis so I ask you if you can help me with something on the same subject but a different problem:

local btns = {}
	
	for i, emote in pairs(emotesF:GetChildren()) do
		
		local btn = script.PlayEmoteButton:Clone()
		local emoteN = emote.Name
		btn.Text = emoteN
		btn.Name = "nombre del boton"

WHICH IS WHAT I WANT?
I am making a system of emotes and what I want to do is to activate an emote press a keyboard enumeration from 1 to 10 to make it faster to play the animation.
WHAT IS THE PROBLEM?
The problem is that I made an emote store, which when I buy one will be added to the list of emotes which has no order and what I want is that each time a button is cloned in the list, each one has a different one name if you can help me thank you very much

To make a frame visible/invisible then copy this script just-in-case that people get stuck on the Emote Gui:

script.Parent:MouseButton1Click:Connect(function()
    if script.Parent.Parent.Frame.Visible == false then -- 1 Parent = The Button, 2 Parents = Let's say, the ScreenGui
        script.Parent.Parent.Frame.Visible = true
    else
        script.Parent.Parent.Frame.Visible = false
    end
end)

As you realized, I typed it with my hands because I used spaces instead of the “bar thingy”.

getting the gui from the starterGui is a common mistake. You have to get it from the playerGui bc that’s where it will be when the player plays the game. Only then can you manipulate the gui properties

local players = game:GetService("Players")
local player = players.LocalPlayer
local playerGui = player.PlayerGui
local gui = playerGui.EmotesGui

*Edit: I just realized someone already said this. :eyes: Do you mind posting a sc of what ur script and explorer tree looks like?

you can use this to do the same thing:

local Button = script.Parent
local Frame = Button.Parent.Frame
Button.MouseButton1Click:Connect(function()
   Frame.Visible = not Frame.Visible
end)