-
What do you want to achieve?
I was making an energy charging script like Dragon Ball Rage
using InputBegan and InputEnded -
What is the issue?
after the input ends, I don’t know how to get the variable of the animation and make the animation stop -
What solutions have you tried so far?
server script
local function startcharge(player,maxki)
local Character = player.Character
local fx1 = game.ReplicatedStorage.Particles.Charge:Clone()
local fx2 = game.ReplicatedStorage.Particles.Spread:Clone()
fx1.Parent = Character.HumanoidRootPart
fx2.Parent = Character.HumanoidRootPart
local animc = script.charge:Clone()
animc.Parent = Character.Humanoid
local animate = Character.Humanoid:LoadAnimation(animc)
animate:Play()
end
local function endcharge(player,maxki)
local Character = player.Character
Character.HumanoidRootPart.Charge:Destroy()
Character.HumanoidRootPart.Spread:Destroy()
Character.Humanoid.charge:Destroy()
end
game.ReplicatedStorage.Events.EnergyCharge.OnServerEvent:Connect(startcharge)
game.ReplicatedStorage.Events.StopEnergyCharge.OnServerEvent:Connect(endcharge)
local script
local Fetch = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
Fetch.InputBegan:Connect(function(inst)
if inst.KeyCode == Enum.KeyCode.C then
local maxki = player.leaderstats.MaximumKi
game.ReplicatedStorage.Events.EnergyCharge:FireServer(maxki)
end
end)
Fetch.InputEnded:Connect(function(inst)
if inst.KeyCode == Enum.KeyCode.C then
game.ReplicatedStorage.Events.StopEnergyCharge:FireServer()
end
end)