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

Need debugging fans to help me with this ~50 line code?

Asked by 9 years ago

note; don't be intimidated by the long code. It's not that bad, and there's only one issue. ;p

I've been working on a rather advanced NPC dialog lately, and I recently made a UI for the NPC's for them to talk alone to the player upon 'triggering' the UI. (in this case, clicking the humanoids head)

The issue resides in the function listed here (and the alikes)

function phr1()
local phrase1 = "Hello"
    for i=1,string.len(phrase1) do 
    textLbl.Text = (string.sub(phrase1,1,i))
        script.Parent.Sound:Play()
        wait(0.04)
    end
end

It seems that during extensive testing, the issue is this particular line.

textLbl.Text = (string.sub(phrase1,1,i))

The issue I've kind of dimmed it down to is that the textLbl is not getting the text it needs, and remains blank. I'm unsure why past that, but if someone could debug this particular function in my code in general, I would be heavily greatful.

Oh uh, sorry for the partial request here for debugging. I'm at a standstill with it and I can't think of any other way to solve it than to get the community here to help me out :P

full script

local GUI = script.Parent.Parent
local NPC = script.Parent.Parent.Parent
local textLbl = script.Parent.TextLabel

function phr1()
local phrase1 = "Hello"
    for i=1,string.len(phrase1) do 
    textLbl.Text = (string.sub(phrase1,1,i))
        script.Parent.Sound:Play()
        wait(0.04)
    end
end

function phr2()
local phrase2 = "How are you doing?"
    for i=1,string.len(phrase2) do 
    textLbl.Text = (string.sub(phrase2,1,i))
        script.Parent.Sound:Play()
        wait(0.04)
    end
end

function phr3()
local phrase3 = "I am an early test bot. Nice to meet you!"
    for i=1,string.len(phrase3) do 
    textLbl.Text = (string.sub(phrase3,1,i))
        script.Parent.Sound:Play()
        wait(0.04)
    end
end

if GUI.Parent == NPC then --checks if parent is NPC.. lol so genius!
    repeat wait(.5) until false --half a second so we don't eff the servers lmao
end --only penalty being user might have a bit of delay with chat. .5~ max

--since this can only be false if the GUI is in player, I have the right to find
--the actual player variable.

local player = game.Players.LocalPlayer


if GUI.Parent == player.PlayerGui then
    phr1()
    wait(2)
    phr2()
    wait(2)
    phr3()
end


--KONNNNNNNNN, Your genius is showing! ; )

Pardon my..uh, notes. Also, if you need to see the directory and where everything is placed in my game, here you go: http://prntscr.com/9c1130

Answer this question