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
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)
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)
Try changing this to game.Player.LocalPlayer.PlayerGui.Shop.Frame . It should fix your issue.
The reason:
You are changing the transparency of the GUI object present in the starter GUI, while the player cannot see any changes in the Starter GUI. The Player can only see the ScreenGUIs present in the Client’s environment, and StarterGUI is not one of them. This might help you:
I suggest you only declare the relevant variables (e.g. Button1) and put the script in the relevant proximity prompt. The rest won’t be needed unless you’re creating a central control system for all the proximity prompts. In this case you would most like use ProximityPromptService.
No problem. I get confused when I see people using ProximityPrompts on the Client, as it’s way simpler just using a Player parameter on the Server side (with some exceptions).
local Exit = script.Parent.Exit
local Shop = script.Parent
Exit.MouseButton1Click:Connect(function()
if Shop.Visible == true then
Shop.Visible = false
else
Shop.Visible = true
end
end)
Your script(remains the same)
local Button1 = script.Parent
Button1.Triggered:Connect(function(Player)
Player.PlayerGui.Shop.Frame.Visible = true
end)
1.your script is located in the prompt
my script is located in the frame
2.what does MouseButton1Down do?
3.Had probs with my recordings but will try to explain.
(I can press the prompt and activate the GUI for the first time then exit it,after exiting it for the first time,I can’t activate the GUI by pressing the prompt again)
MouseButton1Down is essentially reliable, sometimes MouseButton1Click doesn’t work for me.
Try this script:
local Shop = script.Parent
local Button = -- Path to Exit Button
Button.MouseButton1Down:Connect(function()
if Shop.Visible then
Shop.Visible = false
end)