How to handle abilities/powers

I’ll keep this quick and simple, currently i use a 3 script system for making powers or abilities, a local script that listens for a key press which fires a server script that handles the animation which fires all clients to a different local script that handles the effects. The issue with this method is that by the time you get to the effect script, the mouse location which is captured from the first local script, is old or delayed. I was wondering if there is a better method for all of this, preferably one that allows for a more live mouse location.

The mouse position can only be accessed on the client side in Roblox. You may want to work on a faster reply in your ServerScripts. This is the only work around I can think of right now. By sending the mouse position constantly. You’ll have to script out how to deal with that …

local remoteEvent = game.ReplicatedStorage:WaitForChild("MousePositionEvent")
local function captureMousePosition()
    local mouse = game.Players.LocalPlayer:GetMouse()
    local mousePosition = mouse.X -- You can use mouse.Y for the Y-coordinate

local remoteEvent ="RemoteEvent")
remoteEvent.Name = "MousePositionEvent"
remoteEvent.Parent = game.ReplicatedStorage

local function onRemoteEventFired(player, mousePosition)
    print(player.Name .. " sent mouse position: " .. tostring(mousePosition))
    -->whatever you're doing and dealing with the constant call

Untested and not totally what you’re looking for as it’s only doing X the way it is.

i have already worked on getting a faster reply through the server script but the issue is that the server script doesnt send the mouse location to the all client script until part of the animation has finished since that server script handles the animation

im more looking for another way besides just constantly sending the mouse position through a remote event

Ya, tried to make that a constant update on the step, so the other would read it right … I guess that didn’t work. Kind of a long shot. Maybe you could send that to a # Vector3Value set up someplace, then at the last moment on the effect script read the current position from it.

Have the local set: workspace.CurrentMousePos.Value → or where ever you put it.
Have the remote read: CurrentMousePos = workspace.settings.MousePos.Value
just before you set it out.

Not even sure if that will work. I just know you can’t accessed that on the client side.
This may be a work around in this case if it’s is fast enough.

If I understand this correctly, you can ask for the mouse location once the attack is ready to fire.

Unless i’m misunderstanding what you mean, im still not sure how that would work as if the client set that mouse position value, it wouldn’t be able to be viewed by other clients in the all client script?

Instead of getting the mouse on those scripts u could try having a Vector3 value that always has the value of the mouse, u could achieve this by making a loop that gets the mouse position on a local script, then fire a remote event changing the Vector3 value to the mouse pos
Let me know if it fixs ur issue!