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

Local Script is supposed to enable a screen gui when a brick is clicked - Not working??

Asked by 4 years ago

I'm trying to make dialogue appear as a gui by having the player click on an NPC. Here's the local script:

local ClickDetector = script.Parent.ClickDetector

local text1 = "Hello, is there anything you'd like?"
local text2 = "I know you probably did this unintentionally..."
local text3 = "...but you forgot to give me my paycheck for youth employment!"
local text4 = "I see..."
local text5 = ". . ."
local text6 = "But I can't pay you -"
local text7 = "-WHAT?"
local text8 = "You see, you didn't do enough work.."
local text9 = "..you spent too much time talking with your friends, I'm afraid."
local text10 = "Now, don't be late for lunch! ;)"
local text10 = "So much for cleaning that teacher's nasty microwave..."


local function Speak(player)
    local Dialogue = player:WaitForChild("PlayerGui"):WaitForChild("Dialogue")
    local DialogueBox = Dialogue:WaitForChild("DialogueBox")
    local SpeakerBox = Dialogue:WaitForChild("SpeakerBox")

    Dialogue.Enabled = true

    SpeakerBox.Text = "Teacher"
    for i = 1, #text1 do
        SpeakerBox.Text = string.sub(text1, 1, i)
        wait(0.04)
    end

    wait(3)

    SpeakerBox.Text = "You"
    for i = 1, #text2 do
        SpeakerBox.Text = string.sub(text1, 1, i)
        wait(0.04)
    end

end

ClickDetector.MouseClick:Connect(Speak)

The script isn't finished, but the basic part of enabling the gui when the brick is clicked isn't working. This script is the child of the brick. Can someone help me figure out what I'm doing wrong? Thanks in advance.

0
I’m not too familiar with clickdetectors, but idk if they return player who clicked it or not, so I’m not sure what you’re passing as player in the speak function msuperson24 69 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Never mind, the solution was to switch the local script to a regular script.

Ad

Answer this question