So I’m making an ability that when the player goes into a ball and presses space they do a ground slam:
The ability works normally, however when I press space before I activate the ability it slams instantly even though the remote event was fired before it connected:
Here is the code that s connecting the event when the tool is activated:
abilityStorage.maid:GiveTask(ReplicatedStorage.Network.Input.Space.OnServerEvent:Connect(function(otherPlayer)
if otherPlayer ~= player then return end
shared.AbilityService:DeactivateAbility(player, "Heavenly Fall", abilityStorage)
end))
abilityStorage.maid is automatically cleaned up when the ability is deactivated (I checked and it dose get disconnected).
Here is the code that fires the space remote event:
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
InputController.gameProcessedEvent = gameProcessedEvent
if input.KeyCode == Enum.KeyCode.Space then
ReplicatedStorage.Network.Input.Space:FireServer()
end
end)
The only way I was able to prevent this was to just connect to the remote event in another script:
game.ReplicatedStorage.Network.Input.Space.OnServerEvent:Connect(function()
end)
I don’t even need to do anything, it just fixed when I added this. However I dislike the fact that I will probably need to do this will all inputs so if anyone knows how to fix this issue please let me know!