#help with function disconnection
19 messages · Page 1 of 1 (latest)
pretty sure u cant use :Disconnect on functions unless thats just something ive been unaware of
Just add a bool into while true do in punch and set the bool to false when u want the function to stop running
disconnect is a thing ye
function punch()
while INSERT_BOOL do
task.wait()
end
end
--other code whatever
INSERT_BOOL = false -- stop punch
ok ill try
okay just googled it, disconnect does something differently than you expect
You use it to disconnect function from things like :Connect
example:
local connection
connection = script.Parent.Touched:Connect(function(part)
if part.Parent:FindFirstChild("Humanoid")
part.Parent.Humanoid.Health = 0
connection:Disconnect()
end
end)
ic
Hey, I’ve been coding for a while and I haven’t really heard of the :Disconnect() function at all, and I’ve never used it. I was just wondering what it was used for, because it might help me In the long run. My main guess is that it’s to disconnect a function from an event, but I’m not sure, which is why this topic was created.
So hence why it was giving you the error
since you were using it for the wrong things
thx
no worries!