So I have this dude, like a shopkeeper, and inside his model is a proximity prompt. But when I trigger it, my script does not work, nor does it give me errors or whatever I asked it to print. Looks fine to me. What is wrong? Thank you.
local ProximityPrompt = script.Parent
local GUI = game:GetService("StarterGui")
local ShopGui = GUI.ShopGui.MainFrame
local DB = false
function Triggered()
print("1st")
if not DB then
print("2nd")
DB = true
ProximityPrompt.Enabled = false
ShopGui.Visible = true
wait(1)
DB = false
end
end
ProximityPrompt.Triggered:Connect(Triggered)
I know the problem I have come across this alot when I was starting out. You are saying Starter Gui But it actually gets copied to the players gui so instead of saying āstarterguiā you have to get the player and access their player gui.
local ProximityPrompt = script.Parent
local GUI = game.Players.LocalPlayer.PlayerGui
local ShopGui = GUI.ShopGui.MainFrame
local DB = false
function Triggered()
print("1st")
if not DB then
print("2nd")
DB = true
ProximityPrompt.Enabled = false
ShopGui.Visible = true
wait(1)
DB = false
end
end
ProximityPrompt.Triggered:Connect(Triggered)
local ProximityPrompt = script.Parent
local DB = false
ProximityPrompt.Triggered:Connect(function(player)
local GUI = player.PlayerGUI
local ShopGui = GUI.ShopGui.MainFrame
print("1st")
if not DB then
print("2nd")
DB = true
ProximityPrompt.Enabled = false
ShopGui.Visible = true
wait(1)
DB = false
end
end)
also I may be busy in a little so I may not respond
I just tested this and it does not work in a local script you have to use a server script
side note: if you want to make it so that the gui says things then you can use a remote event to connect when they trigger the proximity prompt to your local script inside of your screen gui to change the text. it may sound like alot of work but its really easy.