Animation only plays the humanoid animation

I am a amateur roblox dev
as seen from the title, the animation doesnt play fully, heres a video

local fireable = true
local firingPlayers = {}

local animationId = “17586914668”

local function PlayShotAnimation(humanoid)
if humanoid then
local animation = Instance.new(“Animation”)
animation.AnimationId = “rbxassetid://” … animationId
humanoid:LoadAnimation(animation):Play()
end
end

local function FireShot(player, mp2)
if fireable then
fireable = false

	local character = player.Character
	if not character then return end

	local humanoid = character:FindFirstChildOfClass("Humanoid")
	PlayShotAnimation(humanoid)

	local handle = script.Parent.Handle
	handle.pow:Play()
	handle.Flare.ParticleEmitter:Emit(100)

	local dist = (handle.Flare.WorldPosition - mp2)
	local raycastparams = RaycastParams.new()
	local direction = (mp2 - handle.Flare.WorldPosition).Unit * 999999999999999999
	local direction2 = (mp2 - handle.Flare.WorldPosition).Unit
	raycastparams.FilterDescendantsInstances = character:GetDescendants()
	raycastparams.FilterType = Enum.RaycastFilterType.Blacklist

	local raycast = workspace:Raycast(handle.Flare.WorldPosition, direction, raycastparams)
	local part = Instance.new("Part", script.Parent)
	part.Anchored = true
	game.Debris:AddItem(part, 0.02)
	part.CanCollide = false
	part.CanTouch = false
	part.CanQuery = false
	part.Size = Vector3.new(0.001, 0.001, 0.001)
	part.Transparency = 1
	local att = Instance.new("Attachment", part)
	if raycast then
		if raycast.Instance.Parent:FindFirstChildOfClass("Humanoid") then
			raycast.Instance.Parent:FindFirstChildOfClass("Humanoid").Health -= math.random(10, 15)
		end
		part.Position = raycast.Position
		handle.Beam.Attachment1 = att
	else
		part.Position = handle.Flare.WorldPosition + direction2 * 2000
		handle.Beam.Attachment1 = att
	end

	wait(0.1) 
	fireable = true
end

end

script.Parent.shot.OnServerEvent:Connect(function(player, mp2, firingState)
if firingState then
firingPlayers[player] = mp2
else
firingPlayers[player] = nil
end
end)

game:GetService(“RunService”).Heartbeat:Connect(function()
for player, mp2 in pairs(firingPlayers) do
FireShot(player, mp2)
end
end)

script.Parent.Unequipped:Connect(function()
for player in pairs(firingPlayers) do
firingPlayers[player] = nil
end
end)

1 Like
local fireable = true
local firingPlayers = {}

local animationId = "17586914668"

local function PlayShotAnimation(humanoid)
	if humanoid then
		local animation = Instance.new("Animation")
		animation.AnimationId = "rbxassetid://" .. animationId
		humanoid:LoadAnimation(animation):Play()
	end
end

local function FireShot(player, mp2)
	if fireable then
		fireable = false

		local character = player.Character
		if not character then return end

		local humanoid = character:FindFirstChildOfClass("Humanoid")
		PlayShotAnimation(humanoid)

		local handle = script.Parent.Handle
		handle.pow:Play()
		handle.Flare.ParticleEmitter:Emit(100)

		local dist = (handle.Flare.WorldPosition - mp2)
		local raycastparams = RaycastParams.new()
		local direction = (mp2 - handle.Flare.WorldPosition).Unit * 999999999999999999
		local direction2 = (mp2 - handle.Flare.WorldPosition).Unit
		raycastparams.FilterDescendantsInstances = character:GetDescendants()
		raycastparams.FilterType = Enum.RaycastFilterType.Blacklist

		local raycast = workspace:Raycast(handle.Flare.WorldPosition, direction, raycastparams)
		local part = Instance.new("Part", script.Parent)
		part.Anchored = true
		game.Debris:AddItem(part, 0.02)
		part.CanCollide = false
		part.CanTouch = false
		part.CanQuery = false
		part.Size = Vector3.new(0.001, 0.001, 0.001)
		part.Transparency = 1
		local att = Instance.new("Attachment", part)
		if raycast then
			if raycast.Instance.Parent:FindFirstChildOfClass("Humanoid") then
				raycast.Instance.Parent:FindFirstChildOfClass("Humanoid").Health -= math.random(10, 15)
			end
			part.Position = raycast.Position
			handle.Beam.Attachment1 = att
		else
			part.Position = handle.Flare.WorldPosition + direction2 * 2000
			handle.Beam.Attachment1 = att
		end

		wait(0.1) 
		fireable = true
	end
end

script.Parent.shot.OnServerEvent:Connect(function(player, mp2, firingState)
	if firingState then
		firingPlayers[player] = mp2
	else
		firingPlayers[player] = nil
	end
end)

game:GetService("RunService").Heartbeat:Connect(function()
	for player, mp2 in pairs(firingPlayers) do
		FireShot(player, mp2)
	end
end)

script.Parent.Unequipped:Connect(function()
	for player in pairs(firingPlayers) do
		firingPlayers[player] = nil
	end
end)
1 Like
local tool = script.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local firing = false

local function sendFiringState()
	while firing do
		tool.shot:FireServer(mouse.Hit.p, firing)
		wait(0.1) 
	end
end

mouse.Button1Down:Connect(function()
	if tool.Parent == player.Character then
		firing = true
		sendFiringState()
	end
end)

mouse.Button1Up:Connect(function()
	if tool.Parent == player.Character then
		firing = false
		tool.shot:FireServer(mouse.Hit.p, firing)
	end
end)

tool.Unequipped:Connect(function()
	firing = false
	tool.shot:FireServer(mouse.Hit.p, firing)
end)
(for the server)

`

1 Like

That’s because of the FadeTime when playing an animation. Use AnimationTrack:Play(0).

it worked, thank you very much

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.