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

How do I make a screen GUI show up on a local players screen when They touch a brick?

Asked by 4 years ago

I wanted the screen GUI to pop up on only the players screen who touched it. the game is suppost to be a self paced story game that has talking. But the screen GUI projects to all players? What should I do?

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
-- Server Script
-- Place into a part

local Players = game:GetService("Players") -- Our player service to use the GetPlayerFromCharacter method
local Main = script.Parent -- The part we will check if it's touched
local Gui = script.ScreenGui -- wherever the gui is located, in my case it's inside the script.

Main.Touched:Connect(function(HitTouch)
 local Player = Players:GetPlayerFromCharacter(HitTouch.Parent) -- Our player
 if Player and not Player.PlayerGui:FindFirstChild(Gui.Name) then
   local ClonedGui = Gui:Clone() -- Cloning a replica of the gui we will clone
   ClonedGui.Parent = Player.PlayerGui -- Parenting it to our player's PlayerGui
  end
end)

Setup should look like this. Image

Hope this has helped, have a great day.

0
Um this didn't work in my case. Well I'm not good at scripting so can you explain a little more in detail scubadude440 -5 — 4y
0
Place the script into a part as a 'Script' instance with the code i've provided putted inside the script and the Gui variable need's to be assigned to a screen gui. I've already explained enough in detail. The code does work, as i've tested. User#31525 30 — 4y
Ad

Answer this question