Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
lo_1003 42
3 years ago
Edited 3 years ago

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)
0
Never use mouse.KeyDown as it is deprecated. Use UserInputService instead. Dovydas1118 1495 — 3y

1 answer

Log in to vote
0
Answered by 3 years ago

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.

0
Also, idk why you say 'if 1hT then' thing, I think it is not there. Phyrixia 51 — 3y
0
I will try bro, lo_1003 42 — 3y
0
It works, i guess the problem is the mouse.KeyDown thank you, if i got a problem again i'll reply back. lo_1003 42 — 3y
0
Ok. Phyrixia 51 — 3y
Ad

Answer this question