im creating a barrier for my game that you can unlock using coins but the surface gui doesn’t work
Barrier_handler (player side)
local Barriers = workspace.Barriers
function PromptSetup(promptBill, prompt)
promptBill.Frame.InputFrame.Frame.ButtonText.Text = prompt.KeyboardKeyCode
promptBill.Frame.TextFrame.ActionText.Text = prompt.ActionText
promptBill.Frame.TextFrame.ObjectText.Text = prompt.ObjectText
end
function PromptNew(barrier)
local prompt = barrier.PrimaryPart.PromptAttach.Prompt
local promptBill = barrier.PrimaryPart.PromptAttach.PromptBill
PromptSetup(promptBill)
prompt.PromptShown:Connect(function()
promptBill.Enabled = true
end)
prompt.PromptHidden:Connect(function()
promptBill.Enabled = false
end)
end
function Setup(barrier)
barrier = Barriers["Fungus Forest"] -- this will be barrier value
local Gui = barrier:FindFirstChild("Blocker").SurfaceGui
Gui.Frame.Price.Text = barrier.PrimaryPart.Price.Value
Gui.Enabled = true
Gui.Frame.DimensionName.Text = barrier.Name
end
for i, barrier in pairs(Barriers:GetChildren()) do
Setup(barrier)
PromptNew(barrier)
end
but the error is: Players.matolol2011.PlayerScripts.Barriers_Handler:26: attempt to index nil with 'SurfaceGui'
not the promptBill (promptBillboard: custom proxymity prompt)
ok I recommend using a :WaitForChild() - this function is always used when some things are not loaded yet after play testing, :FindFirstChild() - use this if there are some script that can removing it occasionally
15:26:59.283 Infinite yield possible on 'Workspace.Barriers.Fungus Forest:WaitForChild("Blocker")' - Studio
15:26:59.283 Stack Begin - Studio
15:26:59.284 Script 'Players.matolol2011.PlayerScripts.Barriers_Handler', Line 27 - function Setup - Studio - Barriers_Handler:27
15:26:59.284 Script 'Players.matolol2011.PlayerScripts.Barriers_Handler', Line 34 - Studio - Barriers_Handler:34
15:26:59.284 Stack End - Studio