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

What's wrong with the following script?

Asked by 8 years ago

The following script is placed inside of StarterPack and it works in studio but, not in the game however it has this one bug where it flings my character does anyone know how I would fix the flinging and also how to make it work in-game? So what this script does is when you press shift all of your body parts are anchored then an animation plays and a ParticleEmitter is parented to your torso. If you let go of shift your body parts are unanchored which makes your animation disappear and then the ParticleEmitter that was inside the torso gets removed. Please answer :)!

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local charging = false
local animation = script.Animation1
particles = script.ParticleEmitter:clone()

mouse.KeyDown:connect(function(key)
    if debounce then return end
    debounce = true
    key = string.lower(key)
    if string.byte(key) == 48 then
    charging = true
    local ll = player.Character:FindFirstChild("Left Leg")
    local rl = player.Character:FindFirstChild("Right Leg")
    local la = player.Character:FindFirstChild("Left Arm")
    local ra = player.Character:FindFirstChild("Right Arm")
    local head = player.Character.Head
    player.Character.Torso.Anchored = true
    ll.Anchored = true
    rl.Anchored = true
    local animationTrack = player.Character:findFirstChild("Humanoid"):LoadAnimation(animation)
    animationTrack:Play()
    particles.Parent = player.Character.Torso
    wait(.6)
    la.Anchored = true
    ra.Anchored = true
    head.Anchored = true
    wait(2)
    end
    debounce = false
    end)
mouse.KeyUp:connect(function(key)
    key = string.lower(key)
    if string.byte(key) == 48 then
    charging = false
    player.Character.Torso.Anchored = false
    local ll = player.Character:FindFirstChild("Left Leg")
    local rl = player.Character:FindFirstChild("Right Leg")
    local la = player.Character:FindFirstChild("Left Arm")
    local ra = player.Character:FindFirstChild("Right Arm")
    local head = player.Character.Head
    ll.Anchored = false
    rl.Anchored = false
    la.Anchored = false
    ra.Anchored = false
    head.Anchored = false
    player.Character.Torso.Anchored = false
    particles:remove()
    end
    end)

Answer this question