I am using a proximity prompt in my game. For some reason, using the PromptTriggered event won’t work. Here is my script:
local cookPrompt = script.Parent.CookPrompt
local function showCookingGui(player)
local playerGui = player.PlayerGUI
local cookingGui = playerGui.CookingGUI.CookingGUIFrame
cookingGui.Visible = true
end
cookPrompt.PromptTriggered:Connect(showCookingGui(Plr))
It is saying that PromptTriggered is not a valid member of cookPrompt.
That’s used if you’re trying to call the ProximityPromptService, but it doesn’t seem like you are
Use the Triggered Event instead:
local cookPrompt = script.Parent.CookPrompt
local function showCookingGui(player)
local playerGui = player:WaitForChild("PlayerGui")
local cookingGui = playerGui.CookingGUI.CookingGUIFrame
cookingGui.Visible = true
end
cookPrompt.Triggered:Connect(showCookingGui)
local cookPrompt = script.Parent.CookPrompt
local function showCookingGui(player)
local playerGui = player.PlayerGui
local cookingGui = playerGui.CookingGUI.CookingGUIFrame
cookingGui.Visible = true
end
cookPrompt.Triggered:Connect(showCookingGui(Plr))
local cookPrompt = script.Parent.CookPrompt
local function showCookingGui(player)
local playerGui = player:WaitForChild("PlayerGui")
local cookingGui = playerGui:WaitForChild("CookingGUI"):WaitForChild("CookingGUIFrame")
cookingGui.Visible = true
end
cookPrompt.Triggered:Connect(showCookingGui())
Alright, so if it’s doing infinite yield, waitforchild is taking forever to find that typical child, which then yields the script (pauses) until that action is done.
Try this:
local cookPrompt = script.Parent.CookPrompt
cookPrompt.Triggered:Connect(function(plr)
local playerGui = plr:FindFirstChild("PlayerGui")
local cookingGui = playerGui.CookingGUI.CookingGUIFrame
cookingGui.Visible = true
end)