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

How do I insert Scripts/Gui's into players on touch ?

Asked by 9 years ago

Ok this is my script..

function neon()
  game.lighting.GUINAME.Parent = game.Players.(Im stuck..I need the person who touched its name)
  end

 script.Parent.Touched:connect(neon)

As you can see I need some sort Function/Method what puts the player who touched the blocks name so the script can be completed :/ I've heard something like FindFirstChild too help.. Also if you answer could you also tell me how it works ? I may need this in future projects.

0
I would love for someone to answer I've been stuck with this for weeks D: neonyayaunbanner 0 — 9y

2 answers

Log in to vote
0
Answered by
MrFlimsy 345 Moderation Voter
9 years ago

We need to use an event for this. Also, you should copy the GUI into the player's PlayerGui instead of moving it, or the next person who triggers the event won't get the GUI.

function neon(hit)
--'hit' is the part that touched the brick
    if hit.Parent:FindFirstChild("Humanoid") then
    --check if the brick's parent is a model that contains a humanoid
        local gui = game.Lighting.GUINAME:clone()
        --set 'gui' to a clone of your GUI
        gui.Parent = game.Players:GetPlayerFromCharacter(hit.Parent).PlayerGui
        --get the player from the character model and insert the GUI
    end
end

game.Workspace.PARTNAME.Touched:connect(neon)
--connect the function with a touched trigger
0
Wow thanks so much :D Also is hit a type of method ? neonyayaunbanner 0 — 9y
0
Also where did you learn lua ? (I need somewhere to learn more lua :/) neonyayaunbanner 0 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

If you want even more than one GUI to show up, at random times, use the Math.random() Function, that's what I use when I want something random to happen in a specific order.

Answer this question