Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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.

1 comment

0

I would love for someone to answer I've been stuck with this for weeks D:

2 answers

✓ Accepted answer

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

2 comments

0

Wow thanks so much :D Also is hit a type of method ?

0

Also where did you learn lua ? (I need somewhere to learn more lua :/)

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.