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

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


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

1 comment

0

Do you get any errors?

1 answer

✓ Accepted answer
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.

1 comment

0

You didn't check if it actually was a Player who touched

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