What do you want to achieve?
1° - Activate my Fireball tool.
2° - Check if player have enought mana and canAct(bool variable), from server side, for exploiting prevention.
3° - Play a casting Animation, 2 seconds duration, and create casting effect.
4° - When casting animation end, fire a fireball projectile in the mouse direction.
What is the issue?
I want to do the verifications (2° step), wait for casting animation to end(3° step), and only then fire a fireball in the mouse diretion.
Otherwise it will fire a fireball to direction from 2 seconds ago.
But how i get the mouse direction after these 2 seconds?
What solutions have you tried so far?
I am actually using 2 remote events (Casting and Cast)
1° when the tool is activated
Casting: i check the mana and canAct(boolValue)
2° 2 seconds after the tool has been activated
Cast: receive the mouse direction and instance the fireball projectile
ps. but then i dont know if player passes the verification!
Shortening
How i create this effect using directly 1 server script or
1 local script and only 1 remote event ?
casting effect and animation

projectile in the mouse direction
2 Likes
You mean you want to get the mouse direction?
2 Likes
yes, after 2 seconds that i have been fired the remote event
2 Likes
You can get the player head position and mouse.Hit.Position and create a vector3 by doing (position1 - position2).Unit
2 Likes
sorry i guess you did not understood my Issue.
i dont want to know how to get the mouse direction, its already done.
my issue is a logic problem, that i need to get the mouse direction AFTER 2 seconds of remote event been fired. because have a casting animation and effect before it fire the projectile.
1 Like
Can’t you just get it using delay() or wait() after the remote event had been fired?
3 Likes
You have a RemoteEvent which when fired has an event called RemoteEvent.OnServerEvent
that fires if the RemoteEvent was fired by a client and RemoteEvent.OnClientEvent
that fires when a RemoteEvent is fired by the server. Add a wait(2)
statement after the RemoteEvent fired event and play the animationTrack.
AnimationTrack:
local animationTrack = humanoid:LoadAnimation(animationInstance)
animationTrack:Play()
To know when the animationTrack is completed just use:
animationTrack.Completed:Connect(function()
//Fire the projectile here
end)
3 Likes
if i can get an updated value from where the player is aiming, yes.
because if i add a wait() and not get an updated value, the player will shoot the fireball at direction he was aiming when he started the casting, and the target probably gonna be far from there.
1 Like
you could do
local mousePosition = mouse.Hit.Position
--Create the vector
--Send the vector to the server
wait(2)
mousePosition = mouse.Hit.Position
--Since 2 seconds has past mouse.Hit.Position would give a different value
--Create the vector and send the vector to the server again
2 Likes
Found Solution
this is a shortened version of my the resolution
Thx everyone, for replies!
Tool.LocalScript
fireCastingEvent.OnClientEvent:Connect(function(metRequirements)
if metRequirements == true then
fireballEvent:FireServer(myParams)
end
end)
Tool.Activated:Connect(function()
fireCastingEvent:FireServer(myParams)
end)
FireCasting_RemoteE
if char.Statistics.CanAct.Value == true and char.Statistics.MP.Value >= manaCost then
char.Statistics.MP.Value -= manaCost
-- create casting effect
-- play casting animation
-- wait casting end
fireCastingEvent:FireClient(player, true)
end
Fireball_RemoteE
local function OnFireballEventFired(myParams)
-- create fireball and shoot in mouse direction
end
1 Like