Does anyone know know how to make a sword slash barrage? All I need is the vfx part lol.
local event = game.ReplicatedStorage.Yandere.SwiftSlashesEvent
local TS = game:GetService("TweenService")
local Debris = game:GetService("Debris")
local Slash = game.ReplicatedStorage.Yandere.SlashEffect:Clone()
event.OnServerEvent:Connect(function(plr)
local animation1 = script:WaitForChild("Anim1")
local animation2 = script:WaitForChild("Anim2")
local character = plr.Character
local humanoid = character:WaitForChild("Humanoid")
local anim1 = humanoid:LoadAnimation(animation1)
local anim2 = humanoid:LoadAnimation(animation2)
anim1:Play()
wait(.167)
local slashgoal = {}
slashgoal.CFrame = Slash.CFrame + Vector3.new(0,5,0)
local TI = TweenInfo.new(.5)
local slashtween = TS:Create(Slash, TI, slashgoal)
local yes = true
while yes == true do
anim2:Play()
Slash.CFrame = character.Humanoid.CFrame * CFrame.new(0,3,0)
Slash.Parent = game.Workspace
slashtween:Play()
wait(.2)
end
wait(5)
local yes = false
anim2:Stop()
end)
That wouldn’t work because what’s below the while-loop would never execute.
This is how I would’ve done it based on your code:
AnimationRemote:FireClient(Player, "Barrage", "Play")
local CanBarrage = true
-- much better
task.delay(5, function()
CanBarrage = false
end)
-- I wouldn't do effects on the server, but for the sake of your code here it is
while CanBarrage and Humanoid.Health > 0 do
-- code
end
-- 0.3 is the fade time, e.g: `AnimationTrack:Stop(0.3)`
AnimationRemote:FireClient(Player, "Barrage", "Stop", 0.3)
There is a method for RemoteEvents called FireAllClients, this event would make everything that is listening visible by other players, but why? the client can process information much faster giving players a better experience visualizing the effects.
e.g:
-- Server
local RemoteEvent = ...
RemoteEvent:FireAllClients("Test")
-- Client
local RemoteEvent = ...
RemoteEvent.OnClientEvent:Connect(function(Text)
print(Text) -- all clients listening to this event will print the text sent by the server.
end)