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

part animation script is not working, why is this happening?

Asked by 2 years ago

my animation plays fine however whenever it does my character gets weled to the item rather than the item being welded onto me

local replicatedstorage = game:GetService("ReplicatedStorage")
local event = replicatedstorage:WaitForChild("suicide")

event.OnServerEvent:Connect(function(player,newgun)
    local name = game.Workspace[tostring(player)]
    local humanoid = name:WaitForChild("Humanoid")
    local newgun = replicatedstorage:FindFirstChild("gunfx").Gun:Clone()
    local SA = Instance.new("Animation")
    SA.AnimationId = "rbxassetid://8230012628"
    local Suicide = humanoid:LoadAnimation(SA)
    name.HumanoidRootPart.Anchored = true
    local newgun = replicatedstorage:FindFirstChild("gunfx").Gun:Clone()

    humanoid.BreakJointsOnDeath = false
    newgun.Parent = name.RightHand
    local weld = Instance.new("WeldConstraint")
    weld.Parent = name.RightHand
    weld.Part0 = name.HumanoidRootPart
    weld.Part1 = name.RightHand.Gun 
    newgun.CFrame = name.RightHand.CFrame + Vector3.new(0.076, 0.61,0.209) 

    newgun.gunshotp1.CFrame = name.Head.CFrame + Vector3.new(0.067,0.232,0.597)
    newgun.bulletp1.CFrame = name.Head.CFrame + Vector3.new(0.053,0.265,0.512)
    newgun.bulletp2.CFrame = name.Head.CFrame + Vector3.new(0.053,0.275,0.506)
    print("test")
    Suicide:Play()
    wait(0.94)
    newgun.gunshotp1.Transparency = 0
    wait(0.1)
    newgun.gunshotp1.Transparency = 1
    print("mandem")
    local bul1 = name.RightHand.bulletp1.CFrame
    local bul2 = name.RightHand.bulletp2.CFrame
    local start = bul1
    local endpos1 = bul1 + Vector3.new(0.053,6.399,4.635)
    local start2 = bul2
    local endpos2 = bul2 + Vector3.new(0.053,6.409,4.641)
    for i = 0,1, 0.02 do
        bul1 = start:lerp(endpos1, i)
        bul2 = start2:lerp(endpos2,i)
        wait(0.001)
        print("mest")
    end
    name.HumanoidRootPart.Anchored = false
    newgun.bulletp1:Destroy()
    newgun.bulletp2:Destroy()

end)

1 answer

Log in to vote
0
Answered by 2 years ago

Use the Qperfection weld in the toolbox. Just put it inside your tool and test out your game. It welds all items inside a tool and not to you. Then you can focus on loading your animation

0
i fixed it thanks gymsharklife1 54 — 2y
0
Was my comment the answer? If so press the button that says "This answered" or something, lol. Krektonix_Youtube 85 — 2y
Ad

Answer this question