I am trying to get the text box to appear when you click the key.
local key = script.Parent local click = key.ClickDetector local StarterGui = game:GetService('StarterGui') local scrgui1 = Instance.new("ScreenGui",StarterGui) local function onClick(clicked) key.Transparency = 1 key.Value.Value = true local alert = Instance.new("TextLabel",scrgui1) alert.Text = "You picked up the old key." alert.Position = UDim2.new(0.5,0,0.5,0) wait(2) alert:Destroy() end click.MouseClick:connect(onClick)
You have to place new GUI Objects into player.PlayerGui, as StarterGui is cloned to it only when the player joins or respawns. Assuming you aren't using filtering enabled:
local key = script.Parent local click = key.ClickDetector local function onClick(clicked) key.Transparency = 1 key.Value.Value = true local scrgui1 if not clicked.PlayerGui:FindFirstChild('ScreenGui') then scrgui1 = Instance.new("ScreenGui", clicked.PlayerGui) else scrgui1 = clicked.PlayerGui.ScreenGui end local alert = Instance.new("TextLabel",scrgui1) alert.Text = "You picked up the old key." alert.Position = UDim2.new(0.5,0,0.5,0) wait(2) alert:Destroy() end click.MouseClick:connect(onClick)