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

the part is spawning below me ??

Asked by 2 years ago

i want the part to spawn in my head and go to the tween position however it is spawning below me and not reaching the correct position

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

event.OnServerEvent:Connect(function(player,newgun)
    local tweenservice = game:GetService("TweenService")
    local name = game.Workspace[tostring(player)]
    local tweeninf = TweenInfo.new(
        1,
        Enum.EasingStyle.Sine,
        Enum.EasingDirection.Out,
        1,
        false
    )


    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
    newgun.CFrame = name.RightHand.CFrame + Vector3.new(0.076, 0.61,0.209) 
    newgun.Massless = true
    local weld = Instance.new("Motor6D")
    weld.Parent = name.RightHand
    weld.Part0 = name.RightHand
    weld.Part1 = name.RightHand.Gun.Handle 


    newgun.bulletp1.CFrame = name.Head.CFrame * CFrame.new(0.053,0.265,0.512)
    newgun.bulletp2.CFrame = name.Head.CFrame * CFrame.new(0.053,0.275,0.506)
    print("test")
    Suicide:Play()
    wait(0.8)
    print("mandem")
    local bullet1 = name.RightHand.Gun.bulletp1
    local bullet2 = name.RightHand.Gun.bulletp2
    local bul1 = name.RightHand.Gun.bulletp1.CFrame
    local bul2 = name.RightHand.Gun.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)
    local p1prop= {
        CFrame = bul1 * Vector3.new(0.053,6.399,4.635)
    }
    local p2prop = {
        CFrame = bul2 * CFrame.new(0.053,6.409,4.641)
    }
    local tween1 = tweenservice:Create(bullet1,tweeninf,p1prop)
    local tween2 = tweenservice:Create(bullet2,tweeninf,p2prop)
    tween1:Play()
    tween2:Play()
    name.HumanoidRootPart.Anchored = false
    wait(10)
    newgun.bulletp1:Destroy()
    newgun.bulletp2:Destroy()

end)

thanks in advance

Answer this question