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

How do I make a brick that when On-Touch a GUI Pops up?

Asked by
Maliux 0
10 years ago

(By On-Touch I mean a Person touches it not a brick) How would I make that? I'm new to the Inserting GUIs into someones StarterGUI. Please help :)

2 answers

Log in to vote
1
Answered by
Shawnyg 4330 Trusted Badge of Merit Snack Break Moderation Voter Community Moderator
10 years ago

Not a request site, but since the other guy messed up a bit, I'll lead you towards the correct path.

GUI = game.Lighting["Gui Name Here"] -- Define the path of the GUI (Should not be in the StarterGui)

script.Parent.Touched:connect(function(hit) -- Touched event and connection
    if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) then -- Checks if it's a player. (I use the GetPlayerFromCharacter method just incase you have some other object with a humanoid.)
        p = game.Players:GetPlayerFromCharacter(hit.Parent) -- Sets the Player variable
        if not p.PlayerGui:FindFirstChild("Gui Name Here") then -- Check if they don't have it
            GUI:clone().Parent = p.PlayerGui -- clones it to their PlayerGui
        end
    end
end)
Ad
Log in to vote
0
Answered by 10 years ago

<Edited it a little>

This is not a request site, but this is how:

myGui = game.Lighting:findFirstChild("YourGUINameHere") -- pepps, please, FindFirstChild and findFirstChild works, stop blaming me calling this an error. Try it yourself

function showItNow(part)
 if part.Parent:findFirstChild("Humanoid") ~= nil then
  if game.Players:GetPlayerFromCharacter(part.Parent).PlayerGui:findFirstChild(myGui.Name) == nil then myGui:clone().Parent = game.Players:GetPlayerFromCharacter(part.Parent).PlayerGui end
 end
end

script.Parent.Touched:connect(showItNow)

Hope this helps! Thanks, marcoantoniosantos3

0
Its "FindFirstChild" You need to use capitalization. Also its not script.Parent.onTouch:connect(showItNow) its Touched:connect(showItNow) Vividex 162 — 10y
0
Sorry about event, but no, FindFirstChild and findFirstChild works marcoantoniosantos3 200 — 10y
0
People, let's see if my edit makes your dislike a like. I hope it works for you marcoantoniosantos3 200 — 10y

Answer this question