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

Npc dialogue not restarting ?

Asked by 2 years ago

Hi, so Im making a system where you can chat with other npcs using a gui, but for some reason whenever i press the option to make them leave the conversation, if they come back it still continues from where you left off, and i dont want that. Another thing it does is sometimes it even closes the chatbox even though it only should do it on the last part or when they press the goodbye button. Btw the npc im talking about is the one called god (dont ask)

Help would be appreciated!

Here is the script inside the gui:

local player = game.Players.LocalPlayer
local camera = workspace.CurrentCamera

local page = 1

game.ReplicatedStorage.NPCchat.OnClientEvent:Connect(function(Message,Name,Yes,No)
    script.Parent.NpcName.Text = Name
    script.Parent.Dialogue.Text = Message
    script.Parent.Answer1.Text = Yes
    script.Parent.Answer2.Text = No
    script.Parent.Visible = true

    script.Parent.Answer1.MouseButton1Click:Connect(function()
-- Ignore the noobino part
        if Name == "Noobino" then
            local start = true
            game.ReplicatedStorage.Noobino:FireServer(start)
            script.Parent.Answer1.Visible = false
            script.Parent.Answer2.Visible = false
            script.Parent.Dialogue.Text = "Alright! So first, we have the main area of the Lobby."
            script.Parent.Dialogue.Size = UDim2.new(0.998, 0,0.823, 0)

            repeat
                wait()
                camera.CameraType = Enum.CameraType.Scriptable
                print(camera.CameraType)
            until camera.CameraType

            camera.CFrame = workspace.Lobby.Cameras.Camera1.CFrame

            wait(4.5)

            script.Parent.Dialogue.Text = "Next, we have the shop. This is where you can buy swords & points. One of my brothers also works there!"

            repeat
                wait()
                camera.CameraType = Enum.CameraType.Scriptable
                print(camera.CameraType)
            until camera.CameraType

            camera.CFrame = workspace.Lobby.Cameras.Camera2.CFrame

            wait(6)

            script.Parent.Dialogue.Text = "Here, we have the map voting area where you can vote for the map you want to play on when the next game starts!"

            repeat
                wait()
                camera.CameraType = Enum.CameraType.Scriptable
                print(camera.CameraType)
            until camera.CameraType

            camera.CFrame = workspace.Lobby.Cameras.Camera3.CFrame

            wait(6)

            script.Parent.Dialogue.Text = "This is the credits room, where you can see all the devs and what they did to contribute to the game!"

            repeat
                wait()
                camera.CameraType = Enum.CameraType.Scriptable
                print(camera.CameraType)
            until camera.CameraType

            camera.CFrame = workspace.Lobby.Cameras.Camera4.CFrame

            wait(6)

            script.Parent.Dialogue.Text = "bruh who put this here"

            repeat
                wait()
                camera.CameraType = Enum.CameraType.Scriptable
                print(camera.CameraType)
            until camera.CameraType

            camera.CFrame = workspace.Lobby.Cameras.Camera5.CFrame

            wait(4)

            script.Parent.Dialogue.Text = "Next, this is the hallway for where you can either go to spleef or the obbies."

            repeat
                wait()
                camera.CameraType = Enum.CameraType.Scriptable
                print(camera.CameraType)
            until camera.CameraType

            camera.CFrame = workspace.Lobby.Cameras.Camera6.CFrame

            wait(5)

            script.Parent.Dialogue.Text = "This is Spleef, where you can do stuff i guess"

            repeat
                wait()
                camera.CameraType = Enum.CameraType.Scriptable
                print(camera.CameraType)
            until camera.CameraType

            camera.CFrame = workspace.Lobby.Cameras.Camera7.CFrame

            wait(5)

            script.Parent.Dialogue.Text = "Now, here are the obbies. You can talk with all of the characters there! But whatever you do.. DO NOT do the impossible obby. Bad things have happened there.."

            repeat
                wait()
                camera.CameraType = Enum.CameraType.Scriptable
                print(camera.CameraType)
            until camera.CameraType

            camera.CFrame = workspace.Lobby.Cameras.Camera8.CFrame

            wait(6)



            camera.CameraType = Enum.CameraType.Custom
            script.Parent.Dialogue.Text = "Anyways, that's the introduction to blade fest! You better pay me 1000000000000 points NOW"

            wait(5)

            script.Parent.Visible = false

            script.Parent.Answer1.Visible = true
            script.Parent.Answer2.Visible = true

            script.Parent.Dialogue.Size = UDim2.new(0.998, 0,0.597, 0)

            start = false
            game.ReplicatedStorage.Noobino:FireServer(start)
-- Below is the part im having trouble with
        elseif Name == "God" then
            if page == 1 then
                page = 2
                print(page)
                script.Parent.Answer1.Text = "YES I CAN"
                script.Parent.Dialogue.Text = "You legit cant beat this, stop trying"
            elseif page == 2 then
                page = 3
                print(page)
                script.Parent.Answer1.Text = "YES I CANNNNNNNNNN"
                script.Parent.Dialogue.Text = "YOU CANT"
            elseif page == 3 then
                page = 4
                print(page)
                script.Parent.Answer1.Text = "shut up"
                script.Parent.Dialogue.Text = "YOU LITERALLY CANT WHAT ARE YOU SAYING"
            elseif page == 4 then
                page = 5
                print(page)
                script.Parent.Answer1.Text = "wdym"
                script.Parent.Dialogue.Text = "you cant though"
            elseif page == 5 then
                page = 6
                print(page)
                script.Parent.Answer1.Text = "oh"
                script.Parent.Dialogue.Text = "You'll.. Get banished into a place where no human ever escapes alive"
            elseif page == 6 then
                page = 7
                print(page)
                script.Parent.Answer1.Text = "oh gosh"
                script.Parent.Dialogue.Text = "Youll be suffering endlessly, never ending."
            elseif page == 7 then
                page = 8
                print(page)
                script.Parent.Answer1.Text = "fine"
                script.Parent.Dialogue.Text = "My point is, just dont try it. NOW SCRAM"
            elseif page == 8 then

                page = 1
                print(page)
                script.Parent.Visible = false
            end

        elseif Name ~= "God" or Name ~= "Noobino" then
            script.Parent.Visible = false
        end
    end)

    script.Parent.Answer2.MouseButton1Click:Connect(function()
        page = 1
        script.Parent.Visible = false
    end)
end)

Answer this question