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

Waiting for the player to click a button, why am I getting an error?

Asked by 3 years ago

The game is supposed to wait until a player clicks the "Continue" button, although this doesn't work at all. It instead does nothing and the output gives, "DialogueBox is not a valid member of PlayerGui" which when the dialogue box exists within the StarterGui. (Line 26 of the localScript) Here is the entire script, it's long, and I may have things in the wrong place.

local Controller = require(game.Players.LocalPlayer:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule")):GetControls()
local triggered = false -- Debounce
local UIS = game:GetService("UserInputService") -- Disable Movement

game.ReplicatedStorage.AddyyNPC.OnClientEvent:Connect(function() -- Run on touch
    if triggered == true then
        return nil
    end
    if triggered == false then
        triggered = true
        Controller:Disable()
        game.Workspace.RealAddyy.Head.Interact.Enabled = false
        game.Workspace["Addyy Music"].AddyysMusic.Volume = 0.2
        script.Parent.Parent.DialogueBox.Enabled = true
        workspace.CurrentCamera.CFrame = workspace.CAMS.Dialouge.Addyy.CFrame
        script.Parent.Parent.DialogueBox.NPCName.TextLabel.Text = "???"
        script.Parent.Parent.DialogueBox.Main.TextLabel.Text = "."
        wait(1)
        script.Parent.Parent.DialogueBox.Main.TextLabel.Text = ".."
        wait(1)
        script.Parent.Parent.DialogueBox.Main.TextLabel.Text = "..."
        script.Parent.Parent.DialogueBox.Continue.Visible = true
    end
end)

script.Parent.Parent.DialogueBox.Continue.MouseButton1Click:Connect(function()
    script.Parent.Parent.DialogueBox.Continue.Visible = false
    script.Parent.Parent.DialogueBox.Main.TextLabel.Text = "..."
    script.Parent.Parent.DialogueBox.C1.Text = "Who are you?"
    script.Parent.Parent.DialogueBox.C2.Text = "Hello?"
    script.Parent.Parent.DialogueBox.C1.Visible = true
    script.Parent.Parent.DialogueBox.C2.Visible = true
end)

script.Parent.Parent.DialogueBox.C1.MouseButton1Click:Connect(function() -- Choice 1
    script.Parent.Parent.DialogueBox.C1.Visible = false
    script.Parent.Parent.DialogueBox.C2.Visible = false
    script.Parent.Parent.DialogueBox.Main.TextLabel.Text = "W"
    wait(0.5)
    script.Parent.Parent.DialogueBox.Main.TextLabel.Text = "Wh"
    wait(0.5)
    script.Parent.Parent.DialogueBox.Main.TextLabel.Text = "Who"
    script(0.5)
    script.Parent.Parent.DialogueBox.Main.TextLabel.Text = "Who-"
    script(2)
    script.Parent.Parent.DialogueBox.Main.TextLabel.Text = "Who- O"
    script(0.5)
    script.Parent.Parent.DialogueBox.Main.TextLabel.Text = "Who- Oh"
    script(0.5)
    script.Parent.Parent.DialogueBox.Main.TextLabel.Text = "Who- Oh w"
    script(0.5)
    script.Parent.Parent.DialogueBox.Main.TextLabel.Text = "Who- Oh wh"
    script(0.5)
    script.Parent.Parent.DialogueBox.Main.TextLabel.Text = "Who- Oh who"
    script(0.5)
    script.Parent.Parent.DialogueBox.Main.TextLabel.Text = "Who- Oh who a"
    script(0.5)
    script.Parent.Parent.DialogueBox.Main.TextLabel.Text = "Who- Oh who ar"
    script(0.5)
    script.Parent.Parent.DialogueBox.Main.TextLabel.Text = "Who- Oh who are"
    script(0.5)
    script.Parent.Parent.DialogueBox.Main.TextLabel.Text = "Who- Oh who are y"
    script(0.5)
    script.Parent.Parent.DialogueBox.Main.TextLabel.Text = "Who- Oh who are yo"
    script(0.5)
    script.Parent.Parent.DialogueBox.Main.TextLabel.Text = "Who- Oh who are you?"
end)

script.Parent.Parent.DialogueBox.C2.MouseButton1Click:Connect(function() -- Choice 2
    script.Parent.Parent.DialogueBox.C1.Visible = false
    script.Parent.Parent.DialogueBox.C2.Visible = false
end)

0
this isnt anything to do with the question, but i think there is a better way to make a typewriter effect than to add a character manually niroqeo 123 — 3y
0
Was thinking that. Thanks. User#37681 0 — 3y
0
please make this code cleaner, you could save like 30 lines  WideSteal321 773 — 3y
0
You can just use string.sub to make it clearer, so you don't confuse yourself and easier to read! Feelings_La 399 — 3y

Answer this question