i have a model with a proximity prompt, it gets copied from replicated storage and gets put in workspace, but i when i try to use the proximity prompt the script that handles it doesn’t print anything or do anything
script.Parent.Triggered:Connect(function()
if script.Parent.ActionText == "Open" then
game.Players.LocalPlayer.PlayerGui.ScreenGui["Door Menu"].Visible = true
else
game.Players.LocalPlayer.PlayerGui.ScreenGui["Door Menu"].Visible = false
end
end)
I think it is because you are trying to run a local script inside of the workspace.
Local scripts only run on client environments, I assume this is a local script because you are using the .LocalPlayer object.
Solution: move the script to PlayerGui along with the door you’re using.
Okay, I made a script which will instead of having a script inside of each individual door loop through your DoorsFolder in workspace (if you have one, if not then it’s better to just make one).
This will fire once the player loads in and everytime a new child is added to your DoorsFolder. You can put this in a LocalScript in StarterPlayerScripts.
local Player = game.Players.LocalPlayer
local DoorsFolder = workspace:FindFirstChild("DoorsFolder")
local Debounce = false
repeat task.wait() until Player.Character
function DoorProximityPromptFunction()
for _,DoorProximityPrompt in DoorsFolder:GetDescendants() do
if DoorProximityPrompt:IsA("ProximityPrompt") then
DoorProximityPrompt.Triggered:Connect(function()
if not Debounce then
Debounce = true
if DoorProximityPrompt.ActionText == "Open" then
DoorProximityPrompt.ActionText = "Close"
game.Players.LocalPlayer.PlayerGui.ScreenGui["Door Menu"].Visible = true
else
DoorProximityPrompt.ActionText = "Open"
game.Players.LocalPlayer.PlayerGui.ScreenGui["Door Menu"].Visible = false
end
task.wait()
Debounce = false
end
end)
end
end
end
DoorProximityPromptFunction()
DoorsFolder.ChildAdded:Connect(function()
DoorProximityPromptFunction()
end)
This will not only open GUI but will also change ActionText between Open and Close, you can change this however you want.