part animation script is not working, why is this happening?
my animation plays fine however whenever it does my character gets weled to the item rather than the item being welded onto me
01 | local replicatedstorage = game:GetService( "ReplicatedStorage" ) |
02 | local event = replicatedstorage:WaitForChild( "suicide" ) |
04 | event.OnServerEvent:Connect( function (player,newgun) |
05 | local name = game.Workspace [ tostring (player) ] |
06 | local humanoid = name:WaitForChild( "Humanoid" ) |
07 | local newgun = replicatedstorage:FindFirstChild( "gunfx" ).Gun:Clone() |
08 | local SA = Instance.new( "Animation" ) |
10 | local Suicide = humanoid:LoadAnimation(SA) |
11 | name.HumanoidRootPart.Anchored = true |
12 | local newgun = replicatedstorage:FindFirstChild( "gunfx" ).Gun:Clone() |
14 | humanoid.BreakJointsOnDeath = false |
15 | newgun.Parent = name.RightHand |
16 | local weld = Instance.new( "WeldConstraint" ) |
17 | weld.Parent = name.RightHand |
18 | weld.Part 0 = name.HumanoidRootPart |
19 | weld.Part 1 = name.RightHand.Gun |
20 | newgun.CFrame = name.RightHand.CFrame + Vector 3. new( 0.076 , 0.61 , 0.209 ) |
22 | newgun.gunshotp 1. CFrame = name.Head.CFrame + Vector 3. new( 0.067 , 0.232 , 0.597 ) |
23 | newgun.bulletp 1. CFrame = name.Head.CFrame + Vector 3. new( 0.053 , 0.265 , 0.512 ) |
24 | newgun.bulletp 2. CFrame = name.Head.CFrame + Vector 3. new( 0.053 , 0.275 , 0.506 ) |
28 | newgun.gunshotp 1. Transparency = 0 |
30 | newgun.gunshotp 1. Transparency = 1 |
32 | local bul 1 = name.RightHand.bulletp 1. CFrame |
33 | local bul 2 = name.RightHand.bulletp 2. CFrame |
35 | local endpos 1 = bul 1 + Vector 3. new( 0.053 , 6.399 , 4.635 ) |
37 | local endpos 2 = bul 2 + Vector 3. new( 0.053 , 6.409 , 4.641 ) |
39 | bul 1 = start:lerp(endpos 1 , i) |
40 | bul 2 = start 2 :lerp(endpos 2 ,i) |
44 | name.HumanoidRootPart.Anchored = false |
45 | newgun.bulletp 1 :Destroy() |
46 | newgun.bulletp 2 :Destroy() |