(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 :)
Not a request site, but since the other guy messed up a bit, I'll lead you towards the correct path.
01 | GUI = game.Lighting [ "Gui Name Here" ] -- Define the path of the GUI (Should not be in the StarterGui) |
02 |
03 | script.Parent.Touched:connect( function (hit) -- Touched event and connection |
04 | 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.) |
05 | p = game.Players:GetPlayerFromCharacter(hit.Parent) -- Sets the Player variable |
06 | if not p.PlayerGui:FindFirstChild( "Gui Name Here" ) then -- Check if they don't have it |
07 | GUI:clone().Parent = p.PlayerGui -- clones it to their PlayerGui |
08 | end |
09 | end |
10 | end ) |
<Edited it a little>
This is not a request site, but this is how:
1 | myGui = game.Lighting:findFirstChild( "YourGUINameHere" ) -- pepps, please, FindFirstChild and findFirstChild works, stop blaming me calling this an error. Try it yourself |
2 |
3 | function showItNow(part) |
4 | if part.Parent:findFirstChild( "Humanoid" ) ~ = nil then |
5 | if game.Players:GetPlayerFromCharacter(part.Parent).PlayerGui:findFirstChild(myGui.Name) = = nil then myGui:clone().Parent = game.Players:GetPlayerFromCharacter(part.Parent).PlayerGui end |
6 | end |
7 | end |
8 |
9 | script.Parent.Touched:connect(showItNow) |
Hope this helps! Thanks, marcoantoniosantos3