#Is this how you disconnect()?

1 messages · Page 1 of 1 (latest)

onyx skiff
#
local SRDisc
SRDisc = SoundRemote.OnClientEvent:Connect(function(Instance,Value,NeedParent,Parent)
    if Instance ~= nil then
        if Value == false then
            if Instance.IsPlaying then
                Instance:Stop()
            end
        else
            if NeedParent == true then
                Instance.Parent = Parent
                if not Instance.IsPlaying then
                    Instance:Play()
                end
            else
                if not Instance.IsPlaying then
                    Instance:Play()
                end
            end
        end
        SRDisc:Disconnect()
    end
end)
tawdry tartan
#

the event disconnects itself right after running once because SRDisc:Disconnect() is inside the function, this means the listener won't respond to any other events