ProximityPrompt to open Gui issue

I’m trying to open the Gui via local script using ProximityPrompt and nothing happens. I’m assuming since it’s only for the client that I should use local script to save me the trouble of checking the player who triggered it and then using some game service to connect the server with the player etc etc. but nothing happens. Below are some images to show whether I made mistake somewhere.

image

image

---- Open Gui ----

local proximityPrompt = script.Parent
local buyGui = game.Players.LocalPlayer.PlayerGui:FindFirstChild("BuyNextAreaGui")
local sound = Instance.new("Sound")
sound.SoundId = "rbxassetid://9041161094" -- a short acknowledgement sound for player

proximityPrompt.Triggered:Connect(function()
	buyGui.Enabled = true
	sound:Play() 
end)

proximityPrompt.TriggerEnded:Connect(function()
	proximityPrompt.Enabled = false
	print("Prompt is now off!")
	wait(3)
	proximityPrompt.Enabled = true -- For testing only (remove when done)
	print("Prompt is back on now!")
end)

Welp:
image

I believe having the GUI disabled is the issue, try enabling it, and then rather just set the frame’s visible property to false and change it in the script too

Of course. I wonder why the Local script wasn’t greyed out in Studio (That would’ve given me a hint). Tyvm.

You could create a new local script inside of PlayerScriptService,
then copy and paste this code inside of the newly found script:

local players = game:GetService("Players")

local player = players.LocalPlayer
local part = game.Workspace.Part

part.ProximityPrompt.Triggered:Connect(function(pressed)
    if pressed then
        print(player.Name)
    end
end)

This should at least give you some idea to what is going on…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.