#The text for the dialogue doubles after the first interaction

1 messages Ā· Page 1 of 1 (latest)

charred spade
#

I dont know why it does this but i need help 😭 the first time you talk to him its normal but the second time it breaks

neon spruce
#

can you send the code

#

for the module

charred spade
#

ok

neon spruce
#

whats open doing

charred spade
neon spruce
#

i dont see anything immediately wrong in your code

#

the only thing i can think of is the button.mousebuttton1click event is being called twice

#

so every time the dialogue is activated its being duplicated

#

so there is 1 connection

#

then 2 connections

#

then 3

#

etc

lilac mulch
#

try using string.sub

#

or MaxVisibleGraphemes

neon spruce
#

hes doing ..= letter

#

which should work the same

lilac mulch
#
local TypeWriter = {}

TypeWriter.Type = function(textLabel: TextLabel, text: string, yieldTime: number, sound: Instance?)
    textLabel.MaxVisibleGraphemes = 0
    textLabel.Text = text

    for i = 1, utf8.len(text) do
        if sound and sound:IsA("Sound") then sound:Play() end
        textLabel.MaxVisibleGraphemes += 1
        task.wait(yieldTime)
    end
end

return table.freeze(TypeWriter)``` this module i use it for my current project and it works fine
neon spruce
#

because i think hes connecting it every time the dialogue starts

#

instead of just having it connected once

#

or connecting it then disconnecting it after the dialogue is over

lilac mulch
#

yea maybe he is connecting the connection twice

#

or clicking the button twice or smt

neon spruce
#

it gets connected once evry time the dialogue begins so first time it gets connected once, then a second time, then a third, etc

lilac mulch
#

its causing a memory leak too

#

its better to use :Once

charred spade
lilac mulch
#

it works fine for me

charred spade
#

I'm using a string

lilac mulch
#

u just pass the string and done

charred spade
#

I'll try it but it says there's an error

lilac mulch
charred spade
#

its a bit different but basically the same

charred spade
#

nvm

#

it says theres an error

#

but it still works

lilac mulch
#

but what the error says?

charred spade
#

on the script it says this

lilac mulch
#

r u using strict mode?

charred spade
charred spade
lilac mulch
charred spade
#

uhh

lilac mulch
charred spade
#

yeah but why is it underlined as an error 😭

lilac mulch
#

huh idk

#

anyways if it works

charred spade
#

yeah it does

empty turret
#

what does the error say

charred spade
#

"it does"

#

anyway what i just loaded in and my character didnt load

#

oh well

lilac mulch
#

maybe is deprecated

#

but the documentation doesnt say anything about it

#

and on my module it doesnt show that error

empty turret
#

its possible it doesnt like utf8.len potentially returning 2 values when you only want to use one of them

charred spade
lilac mulch
empty turret
charred spade
#

btw the text doesnt "double" now

empty turret
#

yep its cause the return values are nullable

#

if you want to fix it you can just put or 0 after utf8.len(text)

#

so it defaults to 0 if it returned nil

lilac mulch
#

or just remove the --!strict

empty turret
#

or that