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

How to properly create a charge and release attack?

Asked by
Despayr 505 Moderation Voter
4 years ago

My local scripts and all are just fine. I am just wondering how others do their charge and release attacks.

For instance, I thought it would be a create idea to create a remote listener inside of another remote event. It doesn't feel right.

charge.OnServerEvent:Connect(function(plr)

    local connection
---------------------------------------------------------------------------
--fires when a player releases the held button
    connection = release.OnServerEvent:Connect(function(y)
        if not y == plr then return end
        connection:Disconnect()
        plr.Character.Humanoid:TakeDamage(1)
    end)
--------------------------------------------------------------------------- 

end)

The problem with this method is that everytime another player releases a key, this event will have to check whether they are the initial player or not. Checking several times just for one player doesn't seem right and might take up space if i'm not mistakem.

Would a remote function be better?

Answer this question