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

My dialog shop will not work? why?????

Asked by 5 years ago
script.Parent.DialogChoiceSelected:connect(function(player,dialog)
 local gui = script.Parent.Shop -- Change Shop To The Name Of The Gui.
 if dialog.Name=="DialogChoice" then -- Change The Choice1 To The Name Of The Dialog Choice.
  gui:Clone().Parent = player.PlayerGui
 end
end)

I made a dialog shop that you press a question mark above a bots head and it opens up with questions, you press yes and it opens a GUI. My problem is the GUI will not open when I press Yes

2 answers

Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

Your LocalScript needs to be a descendant of the player, like StarterCharacterScripts. BillboardGuis and SurfaceGuis are the same. Sure, you can see them, but to register user input, they need to be a part of your player locally.

You can do something like the following. This was a test script, so fix the Parents and names.

~ edit based on Parents image in chat

local model = workspace:WaitForChild('player')
local head = model:WaitForChild("Head")
local Dialog = head:WaitForChild("Dialog")
local gui = Dialog:WaitForChild("Shop")

local me = game.Players.LocalPlayer
local playergui = me:WaitForChild("PlayerGui")

Dialog.DialogChoiceSelected:Connect(function(player,choice)
    if choice.Name == 'DialogChoice' then 
        gui:Clone().Parent = playergui
    end
end)
0
:Connect() WideSteal321 773 — 5y
0
:Bacon() Azarth 3141 — 5y
Ad
Log in to vote
-2
Answered by 5 years ago
Edited 5 years ago

Try this:

script.Parent.DialogChoiceSelected:connect(function(player,dialog)
    local gui = script.Parent.Shop
    if dialog.Name=="DialogChoice" then
        local original = gui
        local copy = original:Clone()
        copy.Parent = player.PlayerGui
    end
end)
0
:) PaliKai13 92 — 5y
0
Why does this work. Explain why. WideSteal321 773 — 5y
0
put print("Hi") in between lines 3 and 4 and see if it prints when you click yes. PaliKai13 92 — 5y
0
does it? PaliKai13 92 — 5y
View all comments (2 more)
0
how odd PaliKai13 92 — 5y
0
are you 100% percent sure that the dialog is called "DialogChoice"? PaliKai13 92 — 5y

Answer this question