Player touches brick; he is stored into a variable; you can access his PlayerGUI etc.
I want a GUI to be placed into the Player's PlayerGUI upon touching a brick. How do I get the player?
Using the Touched event, you can have this script as well as the gui you want to show in the player.
local part = script.Parent local gui = part.ScreenGui -- The gui inside the part local debounce = true part.Touched:connect(function(hit) -- The Touched event if debounce then debounce = false local model = hit.Parent if game.Players:findFirstChild(model.Name) and model:findFirstChild("Humanoid") then -- Is a player local add= gui:Clone() add.Parent = game.Players[model.Name].PlayerGui end wait(3) debounce = true end end)
**EDIT: **If you want to store the player's name, say a table then (I haven't tested this so might not work),
playersTouched = {} -- people who touched the brick. local part = script.Parent local gui = part.ScreenGui -- The gui inside the part local debounce = true part.Touched:connect(function(hit) -- The Touched event if debounce then debounce = false local model = hit.Parent if game.Players:findFirstChild(model.Name) and model:findFirstChild("Humanoid") then -- Is a player table.insert(playersTouched, model.Name) local add= gui:Clone() add.Parent = game.Players[model.Name].PlayerGui end wait(3) debounce = true end end)