Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How come my Dialog choice GUI shop wont work?

Asked by 5 years ago

So I have a dialog choice where when you click choice you get a GUI that opens after the NPC's response, but it won't work at all, and the script is in a local script.

---Script---

--- Script type is a local script

script.Parent.DialogChoiceSelected.Response:Connect(function(player, choice)
      game.player.PlayerGui.ShopGui.Frame.Visible = true
    end)

1 answer

Log in to vote
1
Answered by
BuDeep 214 Moderation Voter
5 years ago

Looks like there's a couple of issues, with the first thing being the way you're referencing player.

"game.player" is essentially the same thing as game.Workspace. or game.StarterGui and since "game.player" doesn't exist, your script will throw an error.

Assuming this local script is inside of the PlayersGui it should be rewritten with:

game.Players.LocalPlayer --This is how you reference your player. 

Now another issue is the fact you're using a LocalScript for an Instance that can't use LocalScripts. An easy fix to this is to put a regular Script inside of your Dialog Box, and add the following code:

script.Parent.DialogChoiceSelected.Response:connect(function(plr, choice)
    plr.PlayerGui.ShopGui.Frame.Visible = true --Plr was referenced above so no need for the 'game.'
end)

Assuming you don't have FE (Filtering Enabled) on, the script should work.

0
I'll check vincentthecat1 199 — 5y
0
do i put the local script in the StarterGui or the ScreenGui? vincentthecat1 199 — 5y
0
You don't need a local script. BuDeep 214 — 5y
Ad

Answer this question