I may be dumb but I can`t make it work.. I tried finding a way to do it but it failed and gave me an error (StarterGui is not a member of PlayerGui or something..)
I made this, I know it wont work but I am actually tired.. I have no idea what code should I use to make it work. I know how to read a code but no matter what code I use: It. Never. Works.
local GuiOpener = script.Parent --The part that supposed to open the GUI for me when I touch it local Gui = game.StarterGui.AreYouSure --The GUI that wont show up script.Parent.Touched:connect(function() Gui.TextButton.Visible = true --I have no idea how to use the PlayerGui. end)
Any help please? I really want to develop my game but this one thing wont let me.. :\
Hello there! Since you are referring to startergui, it does not work. All GUI's get cloned from StartedGui to the PlayerGui. The problem is, that "PlayerGui" is located client-sided. Therefore, we must use a remote event.
There are 2 scripts. This has to be in the part itself:
-- Name: "Script" local GuiOpener = script.Parent --The part that supposed to open the GUI for me when I touch it local event = Instance.new("RemoteEvent",game.ReplicatedStorage) event.Name = "OpenAreYouSureGui" GuiOpener.Touched:connect(function(hit) if hit.Parent:FindFirstChild("Humanoid") then local player = game.Players:GetPlayerFromCharacter(hit.Parent) event:FireClient(player) end end)
And this screen has to be in the screengui:
-- Name: "LocalScript" local event = game.ReplicatedStorage:WaitForChild("OpenAreYouSureGui") event.OnClientEvent:Connect(function() script.Parent.TextButton.Visible = true end)
Don't know where to put them?
You are referencing the StarterGui
. Reference the PlayerGui
instead.
local GuiOpener = script.Parent --The part that supposed to open the GUI for me when I touch it local Gui = game.Players.LocalPlayer.PlayerGui.AreYouSure script.Parent.Touched:connect(function() Gui.TextButton.Visible = true end)