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

Character won't play animation and load particles when X button is held?

Asked by 5 years ago

The title says it all, it just won't work. Can someone please help me? The following script is a regular script inside the ServerScriptService. (And just in case, yes I am using R15)

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        wait(2)
        local uis = game:GetService("UserInputService")
        local animation = Instance.new("Animation", workspace)
        animation.AnimationId = "rbxassetid://2405207143"
        local rstorage = game:GetService("ReplicatedStorage")
        local particles = rstorage:WaitForChild("ChargeParticles")
        local normalcharge = particles:WaitForChild("NormalCharge"):GetChildren()
        local char = player.Character
        local torso = player.Character:WaitForChild("UpperTorso")
        local chargeanimation = char.Humanoid:LoadAnimation(animation)
        uis.InputBegan:Connect(function(input,gameprocesed)
            if input.KeyCode == Enum.KeyCode.X then
                chargeanimation:Play()
                wait(.6)
                for _,v in pairs(normalcharge) do
                    if v.Name == "Aura1" or v.Name == "Aura2" or v.Name == "Aura3" then
                        v:Clone().Parent = torso
                    end
                end

            end
        end)

        uis.InputEnded:Connect(function(input,gameprocesed)
            if input.KeyCode == Enum.KeyCode.X then
                chargeanimation:Stop()
                local removeparticles = torso:GetChildren()
                for _, v in pairs(removeparticles) do
                    if v.Name == "Aura1" or v.Name == "Aura2" or v.Name == "Aura3" then
                        v:Destroy()
                    end
                end
            end
        end)
    end)
end)
0
I don't get an error or anything, it just does nothing. supercoolboy8804 114 — 5y
0
UserInputService should be handled on a local script. xPolarium 1388 — 5y

Answer this question