Disconnecting an event created in the client from the server

I want to disconnect the JumpConnection in the server but the connection its created in the client (im using a remote event) , I’ve tried to fire the JumpConnection variable to the server but it doesnt work

This is the local script i dont think its gonna help but whatever


local UserInputService = game:GetService("UserInputService")
local Debris = game:GetService("Debris")
local Debounce = true

local RemoteEvent = game:GetService("ReplicatedStorage").RemoteEvent
local Character = script.Parent
local RootPart = Character.HumanoidRootPart

Character.HumanoidRootPart.Touched:Connect(function(HitPart)

	if Character.Humanoid.FloorMaterial == Enum.Material.Air and Debounce then						
		
		Debounce = false
		
		local JumpConnection			
		JumpConnection = UserInputService.JumpRequest:Connect(function() -- Fires when the player tries to jump	
			RemoteEvent:FireServer(Character, RootPart, JumpConnection)	 
		end)
	end	
		wait(.3)
		Debounce = true	
end)

You could fire the remote event again from the server to client and use the .OnClientEvent:Once listener on the client to avoid memory leaks.

It works thanks a lot dude !!!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.