I’m trying to make 2 functions in one proximity prompt, the first one is to pick up an item, and the 2nd is to display a message on the screen after that item is picked up. But for some reason, I’m only able to pick it up, and the message doesn’t display on the screen.
local handle = script.Parent.Handle
local Text = script.ScreenGui.Frame.Text
local Fade = script.ScreenGui.Frame.Text.Fade
if Key.Parent == workspace then
local proxprompt = Instance.new("ProximityPrompt")
proxprompt.Parent = handle
proxprompt.KeyboardKeyCode = Enum.KeyCode.E
proxprompt.ActionText = "Pick up"
proxprompt.HoldDuration = .5
proxprompt.ObjectText = "Blue Key"
local function onTrigger(player)
for i,v in pairs (script.Parent:GetChildren()) do
if v.ClassName == "ScreenGui" then
c = v:Clone()
c.Parent = player.PlayerGui
end
end
end
proxprompt.Triggered:Connect(function(player)
onTrigger(player)
end)
Fade.Disabled = false
proxprompt.Triggered:Connect(function(Plr)
local backpack = Plr:WaitForChild("Backpack")
Key.Parent = backpack
proxprompt:Destroy()
end)
end