I am going to reiterate what I said earlier in the initial comments I made.
You are not showing the ShopGui for the player that selected the dialog choice, you are changing the visibility of the ShopGui's frame for the ShopGui that is in StarterGui. When a player joins the game, they will receive a copy of this ShopGui that is in StarterGui.
What you need to do is modify the ShopGui inside of the Player's PlayerGui.
If this is being done in a LocalScript, it will be a simple fix.
Note: :connect is deprecated, use :Connect just to be safe because Roblox could remove the functionality of :connect in the future.
script.Parent.DialogChoiceSelected:Connect(function(player, choice)
if player.PlayerGui.ShopGui.Frame.Visible == false then
player.PlayerGui.ShopGui.Frame.Visible = true
end
end)
Now, that's the solution for your problem if you're using a LocalScript.
This is the solution if you're using a server script.
- Insert a RemoteEvent in ReplicatedStorage.
- Insert a LocalScript into StarterGui.
In the LocalScript, type the following.
local Remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
local Player = game.Players.LocalPlayer
local Gui = Player:WaitForChild("PlayerGui"):WaitForChild("ShopGui")
local Frame = Gui:WaitForChild("Frame")
Remote.OnServerEvent:Connect(function()
if Frame.Visible == false then
Frame.Visible = true
else
Frame.Visible = false
end
end)
Modify the server script.
local Remote = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvent")
script.Parent.DialogChoiceSelected:Connect(function(player, choice)
Remote:FireClient(player)
end)
It appears that you inserted the "choice" parameter for this event listener, but did not use it. You don't have to insert parameters that you aren't going to use, unless that parameter is returned(chronologically) before ones that are you are going to use.
This is the full solution. I am a bit drowsy right now, so I could have made some errors. If anyone spots one, or multiple, point it or them out please.
4 comments
Changing the visibility of a frame in StarterGui doesn't do anything for the player selecting the choice, it changes it for people that have yet to join the game, because objects in StarterGui are replicated to a player when they join the game.
If this is being done in a LocalScript, do player.PlayerGui.ShopGui.Frame.Visible instead of StarterGui.ShopGui.Frame.Visible
And if this is being done in a server script, you might want to use a RemoteEvent
I will post an answer because gotta get those rep points somehow y'kno