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

how do i stop a remotefunction script not able to disconnect?

I want to know a bit of knowing how to stop a remotefunction not able to disconnect if i press a E then after that i press 0 I am having this trouble because when i press E then after i press 0. when the 0 keybind script doesnt have ServerInvoke() it just make my remotefunction still on while is not disconnecting, ???

Keybind E Local scripts:

local UIS = game:GetService("UserInputService")
local debounce = true
local plr = game.Players.LocalPlayers

UIS.InputBegan:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.E and Debounce == true then
		Debounce = false
		script.Ora:InvokeServer()
		wait(3.2)
		Debounce = true
	end
end)

RemoteFunction OnServerInvoke scripts:

local HandleBlade = script.Parent.Parent.Parent.Parent.Handle.Handle
local hT  
local dmg = 3

script.Parent.OnServerInvoke = (function() 
	hT = HandleBlade.Touched:Connect(function(hit)
		if hit.Parent:FindFirstChild('Humanoid') then
			hit.Parent.Humanoid:TakeDamage(dmg)
		end
		wait(1)
		if lhT then
			lhT:Disconnect()
		end
	end)
end)

0's LocalScripts:

repeat wait() until game.Players.LocalPlayer

k = game.Players.LocalPlayer:GetMouse()

k.KeyDown:connect(function(key)
	if key == "0" then
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 20
	end
end)

k.KeyUp:connect(function(key)
	if key == "0" then
		game.Players.LocalPlayer.Character.Humanoid.WalkSpeed = 16
	end
end)

1 comment

0

Never use mouse.KeyDown as it is deprecated. Use UserInputService instead.

1 answer

✓ Accepted answer

I believe that the problem is from nothing being returned. In the OnServerInvoke script, you must return something for the invoke, otherwise the function will be sort of stuck. If you don't need a response, you should really use a remote event. You must return something, even if it is nothing proper. I think you should use remote event.

4 comments

0

Also, idk why you say 'if 1hT then' thing, I think it is not there.

0

I will try bro,

0

It works, i guess the problem is the mouse.KeyDown thank you, if i got a problem again i'll reply back.

0

Ok.

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