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

How do I prevent when Welding a part to my Character from freezing the Rig on other Clients?

Asked by 3 years ago

When I Weld a part to my character and play an animation, it works fine on my client but not others. How the script works is the animation is played on my end, an event is fired to the server to then tell the clients to replicate it on their end. All the clients run the same script each with the original client's character as a parameter.

The Part used for animation is Massless, Unanchored, and CanCollide is turned off. It welded to the Character's Right Arm and I have tried using a Weld, WeldConstraint, and Motor6D but the result was the same.

Video Example: https://i.gyazo.com/38c0a8f01981fdebbf6690d5066a1226.mp4

Code Block:

local AnimAttack = Assets["Fire Magic"]["Exploding Fireball"]:Clone()

    -- Position
    local AnimAttackPosition = Character["Right Arm"].CFrame + 
        Character["Right Arm"].CFrame.upVector * (-Character["Right Arm"].Size.Y / 2 - AnimAttack.PrimaryPart.Size.Y * AttackSize / 2 - 2)
    AnimAttack:SetPrimaryPartCFrame(AnimAttackPosition)
    ScaleModel(AnimAttack, AnimSize)

    local Weld = Instance.new("Motor6D")
    Weld.Part0 = Character["Right Arm"]
    Weld.Part1 = AnimAttack.PrimaryPart
    Weld.C0 = Character["Right Arm"].CFrame:inverse()
    Weld.C1 = AnimAttack.PrimaryPart.CFrame:inverse()
    Weld.Parent = AnimAttack.PrimaryPart

    AnimAttack.Parent = workspace.Terrain.Debris

    wait()

    -- Play Animation
    local AnimationTrack = Character.Humanoid:LoadAnimation(Animation)
    AnimationTrack.Priority = Enum.AnimationPriority.Action
    AnimationTrack.Looped = false
    repeat wait() until AnimationTrack.Length > 0
    local SlowAnimationSpeed = (1 / 3) / (Sound.TimeLength / 2)
    spawn(function()
        TweenModelSize(AnimAttack, AnimationTrack.Length / SlowAnimationSpeed / 2, AttackSize / AnimSize, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
    end)
    AnimationTrack:Play(_, _, SlowAnimationSpeed)
    wait(1 / SlowAnimationSpeed * 1 / 3)
    AnimationTrack:Play(_, _, AnimationSpeed)
    AnimationTrack.TimePosition = 1 / 3
    -- End Animation
    Debris:AddItem(AnimAttack, AnimationTrack.Length / AnimationSpeed - AnimationTrack.Length / SlowAnimationSpeed)
    wait(AnimationTrack.Length / AnimationSpeed - AnimationTrack.Length / SlowAnimationSpeed)

Answer this question