Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I make it so a gui shows up for the client using touched events?

Asked by
Loot_O 42
5 years ago

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.

0
Post the script Trollapse 89 — 5y
0
I don't have one, and roblox servers are acting weird, studio too. I can't answer your answers right now... Loot_O 42 — 5y

3 answers

Log in to vote
0
Answered by
BashGuy10 384 Moderation Voter
5 years ago

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)
0
RemoteEvents aren't necessary, but it's a good method. 1ov3y0u 51 — 5y
0
Or remoteFunctions.. Or BindableEvents..... or BindableFunctions.... Or just a regular function in a module script called by a localscript.... JasonTheOwner 391 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

Maybe this:

script.Parent.Touched:connect(function(hit)
  local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
end)

still working on it

0
How do you make lua code like that? Is it like ```Lua -Code- ``? iikinqMxster 9 — 5y
0
There's a button that says Lua when you're writing your answer. Highlight your code and then click the button royaltoe 5144 — 5y
0
Also if you indent it automatically goes to lua code, just a fun fact OBenjOne 190 — 5y
Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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)

0
You should really use remoteevents for stuff like this... BashGuy10 384 — 5y
0
Works fine like this. royaltoe 5144 — 5y
0
yeah use remoteevents FallenZalio 99 — 5y

Answer this question