Error while making a ShopMenu with the Prompt feature

So what I want to do is make a GUI appear when people triggers the Prompt,but it doesn’t work,here’s the script:

Client side:

local Deck = script.Parent.Front

local Button1 = Deck.CypacicIsDream.Attachment.ProximityPrompt

local Button2 = Deck.OnlineGamings.Attachment.ProximityPrompt

local Button3 = Deck.SuperGamingNooby.Attachment.ProximityPrompt

local Button4 = Deck.looileekylielo.Attachment.ProximityPrompt

local ShopGUI = game.StarterGui.Shop.Frame

Button1.Triggered:Connect(function(player)

if ShopGUI.Visible == true then

ShopGUI.Visible = false

else

ShopGUI.Visible = true

end

end)

Server Side:

local ProximityPromptService = game:GetService("ProximityPromptService")

local ServerScriptService = game:GetService("ServerScriptService")

local ObjectActions = require(ServerScriptService.ObjectActions)

-- Detect when prompt is triggered

local function onPromptTriggered(promptObject, player)

ObjectActions.promptTriggeredActions(promptObject, player)

end

-- Detect when prompt hold begins

local function onPromptHoldBegan(promptObject, player)

ObjectActions.promptHoldBeganActions(promptObject, player)

end

-- Detect when prompt hold ends

local function onPromptHoldEnded(promptObject, player)

ObjectActions.promptHoldEndedActions(promptObject, player)

end

-- Connect prompt events to handling functions

ProximityPromptService.PromptTriggered:Connect(onPromptTriggered)

ProximityPromptService.PromptButtonHoldBegan:Connect(onPromptHoldBegan)

ProximityPromptService.PromptButtonHoldEnded:Connect(onPromptHoldEnded)

ObjectAction:

local Deck = game.Workspace.Middle.Shop.Front

local Button1 = Deck.CypacicIsDream.Attachment.ProximityPrompt

local Button2 = Deck.OnlineGamings.Attachment.ProximityPrompt

local Button3 = Deck.SuperGamingNooby.Attachment.ProximityPrompt

local Button4 = Deck.looileekylielo.Attachment.ProximityPrompt

local ShopGUI = game.StarterGui.Shop.Frame

Button1.Triggered:Connect(function(player)

if ShopGUI.Visible == true then

ShopGUI.Visible = false

else

ShopGUI.Visible = true

end

end)

You’re trying to get it from StarterGui, not the Player’s PlayerGui, Just do this for your Triggered code

Button1.Triggered:Connect(function(player)
	local ShopGui = player.PlayerGui.Shop.Frame
	ShopGui.Visible = not ShopGui.Visible
end)

And remove the ShopGUI variable

Because Triggered returns the Player who triggered the event, although for your client sided code, you’d have to change it a bit to this

local plr = game:GetService("Players").LocalPlayer

Button1.Triggered:Connect(function(player)
	if plr ~= player then
		return
	end
	local ShopGui = player.PlayerGui.Shop.Frame
	ShopGui.Visible = not ShopGui.Visible
end)

Because it’ll activate it for everyone

Where do I put these again?
At client or server side?

Anywhere you do

local ShopGUI = game.StarterGui.Shop.Frame

Button1.Triggered:Connect(function(player)
	if ShopGUI.Visible == true then
		ShopGUI.Visible = false
	else
		ShopGUI.Visible = true
	end
end)

Should be where you do the change. If t he Triggered event is on the server, use the first code block, if it’s on the client, use the 2nd code block

Will test this tmr.Thank You for your help.

1 Like

Didn’t work,this is my newest client script:

local Deck = script.Parent.Front

local Button1 = Deck.CypacicIsDream.Attachment.ProximityPrompt

local Button2 = Deck.OnlineGamings.Attachment.ProximityPrompt

local Button3 = Deck.SuperGamingNooby.Attachment.ProximityPrompt

local Button4 = Deck.looileekylielo.Attachment.ProximityPrompt

local ShopGUI = game.StarterGui.Shop.Frame

local plr = game:GetService("Players").LocalPlayer

Button1.Triggered:Connect(function(player)

if plr ~= player then

return

end

local ShopGui = player.PlayerGui.Shop.Frame

ShopGui.Visible = true

end)

Requested module experienced an error while loading - Server - PromptScript:4

local ObjectActions = require(ServerScriptService.ObjectActions)

And what’s the error the module had obtained? And what’s Modulescript code as of now?

actually and don’t want to use the modulescript,I want to script the actions in the local script instead,so how can I change it from calling the module script to the local script (check my server script)