Open Gui Not Working

the interface is just a square at the moment, but I want to make the script first and then play with the interface itself

1 Like

Do you want the Gui object to be shown directly onto the userā€™s screen? I am assuming that is the case since you have ā€œGuiAbilitesā€ inside StarterGui, like this:

1 Like

yes, thatā€™s what I want to do, if I touch a part, it will appear on my screen, if someone else touches that part, it will appear only on his screen

2 Likes

In that case you should do what I suggested earlier if you know how to do it. If you donā€™t then I can try and give you some guidance.

now Iā€™m quite tired, I would need guidance, but I wouldnā€™t want to go and rest knowing that I canā€™t make a script :frowning:

Unfortunately, we are not meant to give free scripts out to people, even though I would like to help. I would however, recommend doing some research yourself and finding something on Youtube or the DevForum for how to set one up.

Once youā€™ve started trying and tell me what you are using and show the setup so far, I will be able to give you some guidance as to how to make it fully work if it doesnā€™t already do so. Hope this helps. :smiley:

So like @FroDev1002 said, you donā€™t really understand, everything in startergui is replicated to the client in a folder called playergui, in this case your using a local script, so all you have to do is replace the abilityList variable to game.Players.LocalPlayer.PlayerGui.GuiAbilities

All credit goes to froDev she figured it out first.

  • SCREENGUI in startergui
  • localscript somewhere the client can access it (inside the ui, startergui, starterplayerscripts, startergear)
  • Path to part
  • what you already have
  • make sure the screengui properties are right, cuz atp i feel like you made the frame invisible and not disabled the screengui

script structure

  • VARIABLES
  • path to part
  • path to localplayer
  • FUNCTION
  • touched,
  • if touched player == localplayer then
  • LocalPlayer.PlayerGui:WaitForChild(ā€œGUIā€).Enabled = true
    OR
  • LocalPlayer.PlayerGui:WaitForChild(ā€œGuiā€).Frame.Visible = true

I knew that, but to start with before @ElectroFLash_1 showed the state of the Explorer menu, I wasnā€™t actually sure if ā€œGuiAbilitiesā€ was an object that existed in PlayerGui, since it would need to be placed in StarterGui for it to work.

Including this case, Iā€™ve never seen a need to directly access PlayerGui, because you would more often than not have the localscript inside the actual ScreenGui in the first place, so there would be no need to directly access it from game.Players.LocalPlayer.PlayerGui in that way or context. Additionally, Iā€™m saying including this case as well because I believe it was incorrectly implied that localscripts could work from parts inside Workspace, or at least when using .Touched in this context which should be done on the server and not on the client I believe; at least in this case if nothing else.

Like I said Iā€™ve never directly tried it with a localscript before, but seeing that itā€™s the use of the server side to complete such task and that I would usually do such a task on the server, I believe that you canā€™t directly access .Touched from a part inside Workspace if your using a localscript instead of a script. Correct me if wrong though.

Nvm most of it has been implemented already. Do you know how you make your ScreenGui visible? Do you enable it through ScreenGui or do you set visibility through another object inside of it? @ElectroFLash_1

This is a reminder, as to what it might look like for anybody who may not know.

Script:

local TouchPart = script.Parent --simplified the directory to not have to go through the whole of workspace

TouchPart.Touched:Connect(function(part) --get .Touched event from TouchPart (script.Parent)
	if part.Parent:FindFirstChildWhichIsA("Humanoid") then
		local Player = game.Players:GetPlayerFromCharacter(part.Parent) --should be game.Players:GetPlayerFromCharacter(part.Parent) not game.Players.GetPlayerFromCharacter(part.Parent)
		if Player then
			local ReplicatedStorage = game:GetService("ReplicatedStorage") --or optionally game.ReplicatedStorage
			local RemoteEvent = ReplicatedStorage:FindFirstChild("ShowGui") --get RemoteEvent
			
			RemoteEvent:FireClient(Player, Player) --pass the player as both 1st and 2nd when being sent to the client
			print("fired!") --optional
		end
	end
end)
--most of code remains the same

Localscript:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RemoteEvent = ReplicatedStorage:FindFirstChild("ShowGui")
local player = game.Players.LocalPlayer -- Get the local player

local GuiAbilities = script.Parent
GuiAbilities.Enabled = false --set to false when game is running

RemoteEvent.OnClientEvent:Connect(function(plrTouched)
	print("fire detected") --optional
	print("player:", plrTouched) --use is optional
	if plrTouched then
		if not GuiAbilities.Enabled then
			GuiAbilities.Enabled = true
		end
	end
end)
--providing that you have some way to close the gui afterwards.

Once you step on the part, it should toggle the gui through the Remote Event. Using one is negligible in this case for exploiters since all they can do is trigger the event for themselves without having to actually step on the part; itā€™s not game-breaking or anything. This is only going to affect the exploiter and nobody else playing the game so you wonā€™t have to worry about that.


Just let me know if you donā€™t want to use that method of toggling whether the Gui is visible or not. It depends on whether you want to toggle the ScreenGuiā€™s visibility directly through .Enabled, or whether you want to set the visibility of another object inside of it using .Visible to toggle when it can be seen and when it canā€™t be. Iā€™m also assuming that you have another way to make the Gui disappear if the user wants to click out of the ā€œAbilityListā€ Screengui.

If this worked for you, mark this post as solved. :smiley:

1 Like

This is what i was thinking, but as @FroDev1002 said, there is supposed to be another way. I cant explain because ive only done this with remote events

I know other people have given you some really great answers but heres my way of doing and iā€™ll explain how it works

so, a remote event should be stored in replicated storage and you should name it something relevant to itā€™s purpose. a remote event allows a server script and a local script to communicate. in your case, you want the server script to fire the event whenever your part is touched and the local script to open the UI. this is because UI is handled for each player individually, hence a local script!

Server Script in ServerScriptService:

local event = game.ReplicatedStorage.UIEvent --this is the event that will be fired
local thePart = game.Workspace.Touchpart --this is the part you want to touch to start the dialogue
local Debounce = false --this will be the cooldown

thePart.Touched:Connect(function(hit) --hit just means you can detect what hit the part and is the most effifient method
	local hum = hit.Parent:FindFirstChild("Humanoid")
	if hum and Debounce == false then
		Debounce = true
		Event:FireClient(game.Players:GetPlayerFromCharacter(hit.Parent))
		wait(10) --this is how long your cooldown is, change it as needed
		Debounce = false
	end
end)

Now, to make the UI appear we use OnClientEvent in our local script. The local script should be parented to the screen GUI, not the dialogue frame or textbox and definetely not StarterGUI itself

Local Script:

--this script is much shorter as we only need to see when the event is fired, and change the UI as needed
local Event = game.ReplicatedStorage.UIEvent --Your even name
local frame = script.Parent.Frame --Your frame name

Event.OnClientEvent:Connect(function() -- knows when the part is touched because we fired the event on the server ONLY when the part gets touched by a player
	frame.Visible = true --makes your frame visible once the part is touched
end)

Hope you understand this way of doing it now, also let me know if it works!

I believe there isnā€™t another way, since localscripts donā€™t run on Workspace objects and you need to include the localscript inside the gui object whilst still being able to detect .Touched on objects in Workspace. For that you need a script inside the object you want to detect and the localscript inside the gui object that you want to show. You canā€™t have one localscript achieving both results I donā€™t think.

1 Like

Yeah, this is what i thought as well. Remote events have always been how iā€™ve done things

Thatā€™s similar to what but just layed it out differently; personal preference of course.


Edit:

Up to you. I checked to make sure mine worked; Iā€™m guessing you did the same thing.

1 Like

Oops, sorry! i didnā€™t read your post and i was just putting my way and trying to explain things. i can delete it if you want

Yes, mine worked. Iā€™ll leave it up if you donā€™t mind. Plus, if yours works better OP can just use thatā€¦ Anyway, iā€™m going to go, have a nice day!

1 Like

Create a server script in this part, write this code and change RunContext to client

local Player = game.Players.LocalPlayer
local AbilityList = Player.PlayerGui:WaitForChild("GuiAbilities")
local TouchPart = script.Parent


TouchPart.Touched:Connect(function(part)
	if part.Parent.Name == Player.Name then
		AbilityList.Enabled = true
		print("Work")
	end
end)
1 Like

it works, but can you explain more precisely how it works? to write down so that I know how to do in the future and to be able to shape the script according to my real requirements :smile:

for example I want to make you canā€™t move when you touch a part and I want to do more things, but I donā€™t want a script, I just want to understand how it works so I can understand how to do everything myself

1 Like