You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I want this animation Track to only play once -
What is the issue? Include screenshots / videos if possible!
As i stated its repeating when the input is processed only once not sure why this is occurring
local rs = game:GetService("RunService")
local remote = game.ReplicatedStorage.RemotesFolder.Movement
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local animator = humanoid:FindFirstChild("Animator")
local PlrMovementMod = require(game.ReplicatedStorage.Modules.PlayerMovement)
local chargeTimer = 0
local MaxInterval = 0.6
local inputHandler = false
local function stopAllAnimations()
for _, track in pairs(char.Humanoid.Animator:GetPlayingAnimationTracks()) do
track:Stop()
end
end
local function UpdateChargingJump(value)
char:SetAttribute("ChargingJump", value)
end
local function increaseChargeValue()
local index = char:GetAttribute("ChargeValue") or 0
char:SetAttribute("ChargeValue", math.min(index + 5, 100))
end
local function chargeValueCleanUp()
char:SetAttribute("ChargingValue", 0)
end
rs.RenderStepped:Connect(function(deltaTime)
PlrMovementMod.Movement(player, char, humanoid, animator)
for _, Track in pairs(animator:GetPlayingAnimationTracks()) do
end
end)
uis.InputBegan:Connect(function(input, isProcessed)
if isProcessed then return end
if input.KeyCode == Enum.KeyCode.Space and not inputHandler then
inputHandler = true
print("input began")
char:SetAttribute("ChargingJump", true)
remote:FireServer("Charging")
local track = animator:LoadAnimation(game.ReplicatedStorage.Animations["Charging Jump"])
track:Play()
track.Stopped:Connect(function()
print("track stopped")
inputHandler = false
end)
end
end)
uis.InputEnded:Connect(function(input, isProcessed)
if isProcessed then return end
if input.KeyCode == Enum.KeyCode.Space then
inputHandler = false
char:SetAttribute("ChargingJump", false)
remote:FireServer("NotCharging")
char:SetAttribute("ChargeValue", 0)
stopAllAnimations()
end
end)
https://gyazo.com/3f56fb89416f6948940e5911985adb5c
This is my local script where im handling the animation and input
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve tried looking on forums for a case similar couldn’t find a topic similar besides that im not sure what to try!