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

Why doesn't this GUI pop up nor does anything happen ?

Asked by 4 years ago

local oGUI = script:FindFirstChild("ScreenGui") script.Parent.Touched:Connect(function(toucher) local player = game:GetService("Players"):FindFirstChild(toucher.Parent) if player then print("Hi!") local GUI = oGUI:Clone() GUI.Parent = player.PlayerGUI wait(1) GUI:Destroy() end end)

I'm trying to create a thing where if you touch it a custom GUI pops up , for some reason nothing happens at all PS: This is a server script

0
Do you get any errors? Spjureeedd 385 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago
local Main = script.Parent -- Our part to touch
local Players = game:GetService("Players") -- Player Service
local Debris = game:GetService("Debris") -- Debris Service
local oGUI = script:FindFirstChild('ScreenGui') -- Our gui

Main.Touched:Connect(function(Hit) -- Touched Connection & Touched Arguement
local Player = Players:GetPlayerFromCharacter(Hit.Parent) -- The player who touched

if oGUI and Player then -- Checking if gui and player exists
  print('Hi!')
  local GUI = oGUI:Clone() -- Cloning our gui
   GUI.Parent = Player.PlayerGui -- Parenting into PlayerGui so player can see it
   Debris:AddItem(GUI, 1) -- waits 1 then gui is destroyed.
 end
end)

Hopefully this suits your needs, tell me if it works.

0
You didn't check if it actually was a Player who touched Spjureeedd 385 — 4y
Ad

Answer this question