I was trying to disconnect two events each in a different block of code(Line 24,Line 50) but I got a error saying:
Event:disconnect() has been deprecated. Use connection object returned by connect()
How would I disconnect the event if it has been deprecated?
local BlueBar = script.Parent.GAME.BluPdl
local RedBar = script.Parent.GAME.RedPdl
local BlueSeat = script.Parent.Parent.Parent.Parent.BlueSeat
local RedSeat = script.Parent.Parent.Parent.Parent.RedSeat
----------------------BlueSeat----------------------------
BlueSeat.ChildAdded:connect(function(Part)--Checks if a Player has been steated
if Part.Name == "SeatWeld" and Part.Part1.Name =="HumanoidRootPart" then
---------------------Vairbles-------------------------
local Character = Part.Part1.Parent
local Player = game.Players:GetPlayerFromCharacter(Character)
local PlayersMouse = Player:GetMouse()
------------------------------------------------------
PlayersMouse.KeyDown:connect(function(Key)
if Key == "w" then
if BlueBar.Position.Y.Offset > 0 then -- Rise Up if pressed w
BlueBar.Position = UDim2.new(0, 0, 0, (BlueBar.Position.Y.Offset - 20))
end
elseif Key == "s" then
if BlueBar.Position.Y.Offset < 400 then
BlueBar.Position = UDim2.new(0, 0, 0, (BlueBar.Position.Y.Offset + 20))
end
BlueSeat.ChildRemoved:connect(function(Part)
if Part.Name == "SeatWeld" and Part.Part1.Name =="HumanoidRootPart" then
PlayersMouse.KeyDown:disconnect()
end
end)
end
end)
end
end)
----------------------RedSeat------------------------------
RedSeat.ChildAdded:connect(function(Part)--Checks if a Player has been steated
if Part.Name == "SeatWeld" and Part.Part1.Name =="HumanoidRootPart" then
---------------------Vairbles-------------------------
local Character = Part.Part1.Parent
local Player = game.Players:GetPlayerFromCharacter(Character)
local PlayersMouse = Player:GetMouse()
------------------------------------------------------
PlayersMouse.KeyDown:connect(function(Key)
if Key == "w" then
if RedBar.Position.Y.Offset > 0 then
RedBar.Position = UDim2.new(0, 560, 0, (RedBar.Position.Y.Offset - 20))
end
elseif Key == "s" then--Rise down if s is pressed
if RedBar.Position.Y.Offset < 400 then
RedBar.Position = UDim2.new(0, 560, 0, (RedBar.Position.Y.Offset + 20))
end
RedSeat.ChildRemoved:connect(function(Part)
if Part.Name == "SeatWeld" and Part.Part1.Name =="HumanoidRootPart" then
PlayersMouse.KeyDown:disconnect()
end
end)
end
end)
end
end)
