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

[SOLVED] ProximityPrompt won't set a frame's visibility to true?

I was using ProximityPrompts to change a frames visibility. It didn't work even though I tried both types of scripts (local and server). While using a server script I got the error

"Workspace.JuicePart.ProximityPrompt.Script:2: attempt to index nil with 'WaitForChild' "

and the local script gave no errors but still didn't work. I also tried using FindFirstChild and that also didn't work.

Code:

local player = game.Players.LocalPlayer
local DrinksFrame = player:WaitForChild("PlayerGui").ShopUi.Drinks

game.Workspace.JuicePart.ProximityPrompt.Triggered:Connect(function() --wait until the ProximityPrompt is triggered 
	print("Juice shop opened")
	wait()
	DrinksFrame.Visible = true -- try to set the visibility to true
end) 

2 answers

I dont think you can use waitforchild on playergui. Not sure tho but try removing the waitforchild

I solved my own question a lot earlier just posting the answer if anyone in the future wants this!

(Nature fresh is a model btw)

local JuicePart = game.Workspace:WaitForChild("NatureFresh").JuicePart.ProximityPrompt
local DrinksFrame = player:WaitForChild("PlayerGui").ShopUi.Drinks

JuicePart.Triggered:Connect(function()
	print("Shop opened")
	DrinksFrame.Visible = true
	wait()
end)

its in a local script and JuicePart is a proximity prompt.

All I changed was I added a variable for the proximity prompt. I think what it was doing before was running this code before the part existed.

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