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

Why do objects stutter when my character throws them?

Asked by 10 years ago

Please include the code which you are trying to use, so the community will be better-equipped to help you with your problem.

Ok, so my place has flashbangs, and when you press G, the animation plays. When the animation is done, the weld that attached the grenade to the arm is destroyed, and the grenade is thrown. But for some reason, after 1/10th of a second, the flashbang sort of stops in mid air then resumes flying a split second later. I have no idea why it's doing this, I tried disabling the scripts to isolate the problem, and I figured out it happens 1/10th of a second after the Weld is destroyed. Any suggestions as to how I would go about fixing this?

EDIT: Added Code

function ThrowGrenade(Grenade)
    _G.MainGui.CrossHair1.Visible = false
    _G.MainGui.CrossHair3.Visible = true
    Humanoid.WalkSpeed = 16
    local Grenade = Grenade:Clone()
    Grenade.Parent = game.Workspace
    for _,v in pairs(Grenade:GetChildren()) do
        if v:IsA("BasePart") and v ~= Grenade:WaitForChild("Center") then
            local Weld = Instance.new("Weld")
            Weld.Part0 = Grenade:WaitForChild("Center")
            Weld.Part1 = v
            Weld.C0 = Grenade.Center.CFrame:toObjectSpace(v.CFrame)
            Weld.Parent = v
            v.Anchored = false
        end
    end
    Grenade:WaitForChild("Center").Anchored = false
    local Weld = Instance.new("Weld")
    Weld.Part0 = FakeRArm
    Weld.Part1 = Grenade:WaitForChild("Center")
    Weld.C0 = _G.GripC0
    Weld.Parent = FakeRArm
    _G.TweenJoint(_G.LWeld2,CF(),CFANG(0,RAD(80),0),_G.Linear,0.25)
    _G.TweenJoint(_G.RWeld2,CF(),CFANG(0,RAD(-80),0),_G.Linear,0.25)
    _G.TweenJoint(_G.LWeld,_G.ArmC0[1],CF(-0.2,0.8,0.1) * CFANG(0,0,RAD(-30)),_G.Linear,0.25)
    _G.TweenJoint(_G.RWeld,_G.ArmC0[2],CF(0.2,0.8,0.1) * CFANG(0,0,RAD(30)),_G.Linear,0.25)
    wait(0.3)

    local Ring = Grenade:WaitForChild("Ring"):Clone()
    Ring.Parent = _G.TextureFolder
    Ring:BreakJoints()

    local RingWeld = Instance.new("Weld")
    RingWeld.Part0 = _G.FakeLArm
    RingWeld.Part1 = Ring
    RingWeld.C0 = _G.FakeLArm.CFrame:toObjectSpace(Ring.CFrame)
    RingWeld.Parent = _G.FakeLArm
    Grenade:WaitForChild("Ring").Transparency = 1

    _G.TweenJoint(_G.LWeld2,CF(),CFANG(0,RAD(45),0),_G.Sine,0.2)
    _G.TweenJoint(_G.RWeld2,CF(),CFANG(0,RAD(-45),0),_G.Sine,0.2)
    _G.TweenJoint(_G.LWeld,_G.ArmC0[1],CF(0,0.8,0.1),_G.Sine,0.2)
    _G.TweenJoint(_G.RWeld,_G.ArmC0[2],CF(0,0.8,0.1),_G.Sine,0.2)
    wait(0.2)

    Ring:Destroy()
    _G.TweenJoint(_G.LWeld2,CF(),CF(),_G.Sine,0.3)
    _G.TweenJoint(_G.RWeld2,CF(),CF(),_G.Sine,0.3)
    _G.TweenJoint(_G.LWeld,_G.ArmC0[1],CF(0,0.5,0.1) * CFANG(RAD(90),0,0),_G.Sine,0.3)
    _G.TweenJoint(_G.RWeld,_G.ArmC0[2],CF(0,0.4,0.1) * CFANG(RAD(-80),0,0),_G.Sine,0.3)
    wait(0.3)

    repeat wait() until (not _G.Keys["g"])

    _G.TweenJoint(_G.RWeld,_G.ArmC0[2],CF(0,0.8,0.1) * CFANG(RAD(-10),0,0),_G.Sine,0.1)
    wait(0.07)

    Weld:Destroy() --This is the weld that holds the grenade to the arm
    Grenade.Center.Velocity = Grenade.Center.Velocity + ((_G.HeadBase.CFrame * CFANG(RAD(10),0,0)).lookVector * 150)
    Grenade.Center.CanCollide = true
    Grenade.Main.Player.Value = Player
    Grenade.Main.Parent = Grenade
    Grenade.Main.Disabled = false

    wait(0.4)

    _G.SwapAnim(0.2)
    _G.MainGui.CrossHair3.Visible = false
end
2
Someone might be able to fix it if you edit your post and have the script there. Lightdrago 95 — 10y
0
Also, that's probably due to lag. Perci1 4988 — 10y
1
Is your script a local script? If so, that could be the issue. That lag could be the time it takes for the server to get the weld removal and then send it back to your client. ipiano 120 — 10y
0
Yes, the script that removes the weld is a local script, but the script also removes welds from magazines and there is no lag at all TurboFusion 1821 — 10y
0
I added the code TurboFusion 1821 — 10y

Answer this question