Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My FPS framework animation doesn't work. How can i fix it?[Fixed]

Asked by 4 years ago
Edited 4 years ago

I'm making a FPS gun, I made the arm and gun, they worked. but arms animation doesn't work. this is the script about arms animation. this is a LocalScript in my gun tool.

wait(.5)
local tool = script.Parent
local cam = workspace.CurrentCamera
local gun = game.ReplicatedStorage:FindFirstChild("K2Rifle") 
local fps_hold = gun.Humanoid:LoadAnimation(gun.Hold) --animation load
holding = false --when i hold a gun, it'll be true

for i,v in pairs(gun:GetChildren()) do
    if v:IsA("BasePart") then
        if v ~= gun.PrimaryPart then
            local weld = Instance.new("Weld")
            weld.Part0 = gun.PrimaryPart
            weld.Part1 = v
            weld.C0 = gun.PrimaryPart.CFrame:inverse()
            weld.C1 = v.CFrame:inverse()
            weld.Name = v.Name
            weld.Parent = gun.PrimaryPart
        end
    end
end

run.RenderStepped:connect(function() 
    if holding == true then
gun:SetPrimaryPartCFrame(gun:GetPrimaryPartCFrame():lerp(cam.CFrame*CFrame.new(0,-2,.2),.3))
    end
end)

tool.Equipped:connect(function()
    for i ,v in pairs(tool:GetChildren()) do
        if v:IsA("BasePart") then
            v.Transparency = 1
        end
    end
    holding = true
    gun.Parent = cam
    fps_hold:Play()
end)
--when i hold a gun, arms will show up on the screen.then animation should play.

tool.Unequipped:connect(function() 
    gun.Parent = game.ReplicatedStorage
    holding = false
    fps_hold:Stop()
end)

i tried with this script. but the animation doesn't work :(

0
why do u have a Humanoid in the gun? Luka_Gaming07 534 — 4y
0
I fixed it, but thank you for trying! UUUIOPandUIN 0 — 4y

Answer this question