Hello, I have a big problem with the script of my tool.
I created an animation with a custom character but the character did not play it (the animation is ARI_Anims.Equipped).
The animations for the movement of the character works but this animation no and I do not know why… (The animation priority are Movement).
By the way, the animation priority was Action and I tried to set it as Action 4 but it did not change anything.
https://gyazo.com/7e6f35ec6888907b53493139ab7677ab
local rf = game:GetService("ReplicatedFirst")
local runs = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")
local TweenS = game:GetService("TweenService")
local plrs = game:GetService("Players")
local tool = script.Parent
local equipped = false
local endreloaded = true
local zoomed = false
local ACTION_RELOAD = "Reload"
local CAMERA = workspace.CurrentCamera
local plr = plrs.LocalPlayer
repeat wait(1) until plr.CharacterAdded ~= nil
local GUI = script.Parent.ARI
local LastAmmo = plr.Ammos.ARI
local mouse = plr:GetMouse()
local humanoid = plr.Character:FindFirstChildOfClass("Humanoid")
local function loadanimation(anim)
return humanoid.Animator:LoadAnimation(anim)
end
local ARI_Aims = {
Equipped = loadanimation(rf.Animations.ARI.ARIEquipped),
Zoom = loadanimation(rf.Animations.ARI.ARIZoom)
}
local fired = false
tool.Equipped:Connect(function()
if not ARI_Aims.Equipped.IsPlaying then ARI_Aims.Equipped:Play() end
equipped = true
local lastammos = plr.Ammos.ARI
GUI.Parent = plr.PlayerGui
GUI.Enabled = true
runs.Stepped:Connect(function()
if equipped then
-- Ammos Config
GUI.Frame.Ammo.Text = lastammos.Value
end
end)
mouse.Button1Down:Connect(function()
if equipped then
fired = true
while fired do
if lastammos.Value > 0 then
lastammos.Value -= 1
end
wait(0.07)
end
end
end)
mouse.Button1Up:Connect(function() if equipped then fired = false end end)
mouse.Button2Down:Connect(function()
if equipped then
if ARI_Aims.Equipped.IsPlaying then
ARI_Aims.Equipped:Stop()
end
if not ARI_Aims.Zoom.IsPlaying then
ARI_Aims.Zoom:Play()
end
CAMERA.FieldOfView = 55
end
end)
mouse.Button2Up:Connect(function()
if equipped then
if not ARI_Aims.Equipped.IsPlaying then
ARI_Aims.Equipped:Play()
end
if ARI_Aims.Zoom.IsPlaying then
ARI_Aims.Zoom:Stop()
end
CAMERA.FieldOfView = 70
end
end)
local function handleAction(actionName, inputState, inputObject)
if actionName == ACTION_RELOAD and inputState == Enum.UserInputState.Begin then
if endreloaded and lastammos.Value < 35 then
endreloaded = false
local realoadFolder = tool.Reload
local zoomFolder = tool.Zoom
local function updateTransparency(folder, value, mode)
for i,v in ipairs(folder:GetChildren()) do
if v:IsA("BasePart") or v:IsA("MeshPart") or v:IsA("Part") then
if mode == "Tween" then
v.Transparency = 0
local anim = TweenS:Create(v, TweenInfo.new(0.5), {Transparency = value})
anim:Play()
wait(0.005)
else
v.Transparency = value
end
end
end
end
updateTransparency(tool, 1, "normal")
updateTransparency(zoomFolder, 1, "Tween")
updateTransparency(realoadFolder, 1, "Tween")
wait(0.5)
updateTransparency(realoadFolder, 0, "normal")
wait(0.5)
updateTransparency(realoadFolder, 1, "normal")
updateTransparency(zoomFolder, 0, "normal")
updateTransparency(tool, 0, "normal")
lastammos.Value = 35
endreloaded = true
end
end
end
ContextActionService:BindAction(ACTION_RELOAD, handleAction, true, Enum.KeyCode.R)
end)
tool.Unequipped:Connect(function()
equipped = false
zoomed = false
CAMERA.CameraType = Enum.CameraType.Custom
CAMERA.FieldOfView = 70
ContextActionService:UnbindAction(ACTION_RELOAD)
GUI.Parent = tool
GUI.Enabled = false
fired = false
wait(0.3)
local animtracks = humanoid:GetPlayingAnimationTracks()
for i,v in pairs(animtracks) do
if v.Name == "ARIEquipped" then
v:Stop()
elseif v.Name == "ARIZoom" then
v:Stop()
end
end
end)