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

How do you make NPC dialog from ScreenGuis?

Asked by 8 years ago

I want it so when you click on the NPC that the dialog appears. It shows that I can click on it but the dialog isn't popping up. This is the script that I am using.

01NPC = script.Parent
02Screen = game.StarterGui.FirstTextGui
03Frame = Screen.FirstTextBox
04Text = Frame.FirstText
05Button = Text.NextButton
06Talk = false
07 
08function onClicked()
09    if Talk == false then
10        Screen.Enabled = true
11        Frame.Visible = true
12        Text.Visible = true
13        Button.Visible = true
14        Talk = true
15    elseif Talk == true then
View all 24 lines...

It doesn't seem to work so please try to help me as much as possible since I am very new at Lua.

1 answer

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

this is the first question I've ever answered I've tested it, it works :) using the StarterGui is not a good way to store your information or gui idk you should maybe store it somewhere like inside of the ReplicatedStorage or simply just inside the script

quick thing yu don't need all that Visible stuff if so throw it into one frame and only visible that one

your error was that in the startergui it enables but that doesn't show to anyone if it was to work it would throw it into everyone screen so coding has to know where to put it im probably really bad at explaining lol

01wait(0.25)
02local NPC = script.Parent
03local Screen = script:WaitForChild('FirstTextGui')
04local Talk = false
05 
06function onClicked(player) -- the player which clicked
07local startergui = player:WaitForChild('PlayerGui') -- the players gui shown only on the for them
08local screen = Screen:Clone() -- clone it
09    if Talk == false then
10        screen.Parent = startergui -- now paste it into the players gui
11        Talk = true
12    elseif Talk == true then
13        if startergui:FindFirstChild(Screen.Name) then -- if found the gui
14        startergui:FindFirstChild(Screen.Name):Destroy() -- kill it
15        end
16        Talk = false
17    end
18end
19 
20NPC.ClickDetector.MouseClick:connect(onClicked)

if it doesn't work uhh your doing something wrong

hopefully it works click the answer button :D cuz I need to answer one question atleast

0
This is fantastic! I had to tinker it a little bit, but it still worked fine! marioblast1244 113 — 8y
0
:D rareheaddress 74 — 8y
Ad

Answer this question