Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.