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

Why does my dialog event not disconnect, even though there are no errors in the output?

Asked by 4 years ago
local P = game.Players.LocalPlayer
local M = P:GetMouse()
local connection

function Dialog(Text)
    for i = 1, #Text do
        script.Parent.ChatText.Text = string.sub(Text, 1, i)
        wait(0.03)
    end
end

M.Button1Down:connect(function()
Dialog("Welcome to CV!")
connection:Disconnect()
end)
connection = M.Button1Down:Connect(function()
end)

1 answer

Log in to vote
0
Answered by 4 years ago

You are binding the connection to another button1down Event, do this

local P = game.Players.LocalPlayer
local M = P:GetMouse()
local connection

function Dialog(Text)
    for i = 1, #Text do
        script.Parent.ChatText.Text = string.sub(Text, 1, i)
        wait(0.03)
    end
end
function mouseDown()
Dialog("Welcome to CV!")
connection:Disconnect()
end
connection = M.Button1Down:Connect(mouseDown)

If this helped, mark this as answered :D

Ad

Answer this question