When I looked up this question like this, I got something like game.Players.Localplayer.PlayerGui
and it makes me ask some other questions like "How do I access the PlayerGui?", "How do I add the guis inside the PlayerGui?". I want a simple explanation so I can make my dialog script work. If someone can help me, please explain it to me in a simple way.
How do I make it so a gui shows up for the client using touched events?
3 answers
A simple way to do this, is: Using remotevents
To make something like this, insert a part, into workspace a remotevent replicatedstorage name the remoteevent "OpenGui", now create a server script inside the part and a local script inside the screengui
Server script
script.Parent.Touched:Connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
game.ReplicatedStorage.OpenGui:FireClient(plr)
end)
Local script
game.ReplicatedStorage.OpenGui.OnClientEvent:Connect(function()
script.Parent.Frame.Visible = true -- Change frame to what ever the frame name is
end)
2 comments
RemoteEvents aren't necessary, but it's a good method.
Or remoteFunctions.. Or BindableEvents..... or BindableFunctions.... Or just a regular function in a module script called by a localscript....
Maybe this:
script.Parent.Touched:connect(function(hit)
local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
end)
still working on it
3 comments
How do you make lua code like that? Is it like ```Lua -Code- ``?
There's a button that says Lua when you're writing your answer. Highlight your code and then click the button
Also if you indent it automatically goes to lua code, just a fun fact
PlayerGui is basically StarterGui but when a player joins all of the contents of StarterGui go into PlayerGui.
You can get playergui by doing something like local playergui = game.Players.LocalPlayer:WaitForChild("PlayerGui")
WaitForChild waits for the gui to be inside the player before it gets it.
Just add your guis in startergui and every gui will pop up there! If you have anymore questions feel free to dm on discord fefe#0449 or comment
-- EDIT
Just realised your question sorry
local part = --Put your part directory here
part.Touched:Connect(function(hit)
local character = hit.Parent.Parent
local player = game.Players.LocalPlayer
-- Your gui stuff here
gui.Visible = true
end)
3 comments
You should really use remoteevents for stuff like this...
Works fine like this.
yeah use remoteevents
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Post the script
I don't have one, and roblox servers are acting weird, studio too. I can't answer your answers right now...