Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Animations look fine in editor but become jerky when played?

My animations are smooth when I play them in the animation editor, but when played in-game, they look weird and choppy. I've looked at others describing the same issues, but the solutions either don't work for me (such as animation weights and priorities) or are outdated.

Video of both editor and in-game animation: https://streamable.com/d9dqr7

Code used to play counterattack animation (local script):

local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local debounce = false
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local swordDamage = ReplicatedStorage.SwordDamageRemoteFunction
local beingUsed = ReplicatedStorage.BeingUsedRemoteFunction
local CurrentAction = script.Parent.Parent.CurrentAction.Value

--[[local AudioPlayerModule = require(ReplicatedStorage:WaitForChild("AudioPlayer")
AudioPlayerModule.preloadaudio({

})]]

--[[
11768323667 right
11768327293 up
11768331665 left
]]

repeat wait() until character.Humanoid
local humanoid = character.Humanoid
local anim = Instance.new("Animation")
anim.Parent = humanoid
anim.AnimationId = "https://www.roblox.com/asset/?id=11762237171"--11749156719
local playAnim = humanoid:LoadAnimation(anim)

UserInputService.InputBegan:Connect(function(Input , IsTyping)
	if not IsTyping and not debounce and Input.UserInputType == Enum.UserInputType.MouseButton1 then
		debounce = true
		wait(0.1)
		playAnim:Play(0, 1, 1)
		CurrentAction = "Slice"
		swordDamage:InvokeServer(character.SliceDamage.Value, true, 0.5, true)
		--sound goes here
		--AudioPlayerModule.playAudio("")
	end
	local seconds = 0
	repeat seconds += 0.1 wait (0.1) until seconds >= 2 or CurrentAction ~= "Slice"
	playAnim:Stop()
	swordDamage:InvokeServer(0, false, false, false)
	beingUsed:InvokeServer()
	if seconds >= 2 then
		CurrentAction = nil
	end
	debounce = false
end)

Code used for idle animation (local script):

local tool = script.Parent
local anim = Instance.new("Animation")
anim.AnimationId = "http://www.roblox.com/Asset?ID=11749602892"
local track
tool.Equipped:Connect(function()
	track = script.Parent.Parent.Humanoid:LoadAnimation(anim)
	track.Priority = Enum.AnimationPriority.Action
	track.Looped = true
	track:Play()
end)
tool.Unequipped:Connect(function()
	if track then
		track:Stop()
	end
end)

1 answer

It seemed to lag when it printed "table reset" Is that a bulky table or something lol?

2 comments

0

No, I was just using it to fix a bug where the sword wasn't doing damage. The table just keeps track of enemies that have been hit during a swing

0

Specifically, the animation seems to move between keyframes very snappily, as opposed to the smoother movements in the editor

This discussion is preserved as it was. New answers, comments, and votes are closed.