Open Gui Not Working

local AbilityList = game.StarterGui.GuiAbilities
local TouchPart = script.Parent


TouchPart.Touched:Connect(function(part)
	if (part.Parent:FindFirstChildWhichIsA("Humanoid")) then
		local player = game.Players.GetPlayerFromCharacter(part.Parent)
			AbilityList.Enabled = true
			print("Work")
	end
end)

i use this script, but not working, why?

1 Like

Ok so from the look of things you dont seem to understand how this works (in the nicest way possible lol)
So let me try to explain what happens.
When you start a roblox game, all GUI inside of StarterGui is cloned to be in PlayerGui, all players can see the Gui that is in PlayerGui, not StarterGui as it is just a place that holds the Gui.

To fix you’re code you would need to get the Gui from inside of the player like so:

local Gui = player.PlayerGui.NAMEOFYOURGUI
1 Like

still not working, where did I go wrong this time?

local AbilityList = game.Player.PlayerGui.GuiAbilities

Can you show me your full code?

local AbilityList = game.Player.PlayerGui.GuiAbilities
local TouchPart = script.Parent


TouchPart.Touched:Connect(function(part)
	if (part.Parent:FindFirstChildWhichIsA("Humanoid")) then
		local player = game.Players.GetPlayerFromCharacter(part.Parent)
			AbilityList.Enabled = true
			print("Work")
	end
end)

i use localScript

Ok so you cant get the Gui cause you dont have the player yet, look at your code, game.Player isnt a thing just so ya know (sorry if that sounds harsh), you need to use game.Players.LocalPlayer,this will give you the local player, which in this case is what ya need!

StarterGui puts a screen gui into the PlayerGui, inside the player in the Players service. To open the ui from a remote script, you need to call the player, so game.Players[the players name].PlayerGui[Your gui name].Enabled = true should do the trick.

local AbilityList = game.Player.PlayerGui.GuiAbilities
local TouchPart = script.Parent


TouchPart.Touched:Connect(function(part)
	if (part.Parent:FindFirstChildWhichIsA("Humanoid")) then
		local player = game.Players.GetPlayerFromCharacter(part.Parent)
			AbilityList.Enabled = true
			print("Work")
	end
end)

that’s how I tried and it doesn’t work

You cant get the Gui like this!!!

local AbilityList = game.Players.LocalPlayer.PlayerGui.GuiAbilities
local TouchPart = script.Parent


TouchPart.Touched:Connect(function(part)
	if (part.Parent:FindFirstChildWhichIsA("Humanoid")) then
		local player = game.Players.GetPlayerFromCharacter(part.Parent)
			AbilityList.Enabled = true
			print("Work")
	end
end)

Try that, see again game.Player isnt a thing, Game.Players is, game.Players allows you to get the local player which is what we need in this case

I tried it doesn’t work, where is the mistake???

First off wheres you script parented? Are there any errors in the out put? Also try this:

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


TouchPart.Touched:Connect(function(part)
	if (part.Parent:FindFirstChildWhichIsA("Humanoid")) then
		local player = game.Players.GetPlayerFromCharacter(part.Parent)
			AbilityList.Enabled = true
			print("Work")
	end
end)

it doesn’t work, I tried both local script and server script

Ok first off this needs to be a local script, second where is it parented? Are there any errors in the output?

Its not about that. You need to put the AbilityList variable inside the function. We can’t write code for you, but screw it. You need to put local AbilityList = player.PlayerGui["GuiName"] after the player variable.

1 Like

It can’t run locally because it is in a part.

OHH wait yeah thats a good point. Ok
@ElectroFLash_1 parent this script in like StarterPlayerScripts, or heck in your UI and then do this:

local TouchPart = workspace.TouchPart -- this assumes that the parts name is TouchPart and it is parented to the workspace. If it isnt named TouchPart then please rename it to that and make sure it is parented to the workspace

Please read the comment for the script

it is not received, but I have no errors either

local AbilityList = game.Players.LocalPlayer.PlayerGui.GuiAbilities
local TouchPart = workspace.Obby.SelectAbilityRing.Part


TouchPart.Touched:Connect(function(part)
	if (part.Parent:FindFirstChildWhichIsA("Humanoid")) then
		local player = game.Players.GetPlayerFromCharacter(part.Parent)
		AbilityList.Enabled = true
		print("Work")
	end
end)

this is how I modeled it and somewhere I keep making mistakes

1 Like

Where is “GuiAbilites” located before the game starts?

Ok look I advise with all my heart and soul that you put this down and go learn the basics, it will help you SO MUCH with this problem to the point it wouldnt be a problem!! It’d help you out a lot!!!
Also where did you parent this script?

Anyhow my guess is that you need to use :WaitForChild() when you go to get the gui, I’d give you the code but this is a time where you need to learn, so to help ya out:

[spoiler]
Hint all you need to do is

game.Players.LocalPlayer -- then by reading the document I sent you add the wait for child here so you can wait for your Gui to load in!

[/spoiler

If you have any more questions feel free to ask, but first try everything I said and read everything I said, itll help a lot

1 Like

You need to use remote events. The server will fire the remote event when the part is touched and the client will make the gui become visible when the event is fired. If you have questions on how to do this exactly, just ask.

Hope this helps