#Basic Scripting. Got my script working, broke it while trying to add particles. More info in desc.

1 messages · Page 1 of 1 (latest)

spring arch
#

I made a script that provides sprinting, dashing upwards, and dashing forwards. I got it all to work then broke it while trying to add particles. Would very much appreciate it if someone could explain to me where I messed up.

#
local Userinputservice = game:GetService("UserInputService")
local CurrentlySprinting = false
local SpeedChangePercentage = 2.1
local player = script.Parent
local Humanoid = player:WaitForChild("Humanoid")
local UpDashCooldown = false
local Keybind = Enum.KeyCode.LeftControl
local UpDashCooldownGUI = game.Players:GetPlayerFromCharacter(script.Parent).PlayerGui.ScreenGui.UpDashImage
local UpDashCooldownGUIText = game.Players:GetPlayerFromCharacter(script.Parent).PlayerGui.ScreenGui.UpDashCooldown
local UpDashCooldownTime = 35
local DashCooldown = false
local DashImage = game.Players:GetPlayerFromCharacter(script.Parent).PlayerGui.ScreenGui.DashImage
local DashCooldownGUIText = game.Players:GetPlayerFromCharacter(script.Parent).PlayerGui.ScreenGui.DashCooldown
local DashCooldownTime = 15
local DashParticle = game.ServerStorage.DashParticle

Userinputservice.InputBegan:Connect(function(input, gameprocessedevent)
    if input.KeyCode == Keybind then
        if CurrentlySprinting == false then
            CurrentlySprinting = true
            Humanoid.WalkSpeed = Humanoid.WalkSpeed * SpeedChangePercentage
        end
    end
end)

Userinputservice.InputEnded:Connect(function(input, gameprocessedevent)
    if input.KeyCode == Keybind then
        if CurrentlySprinting == true then
            CurrentlySprinting = false
            Humanoid.WalkSpeed = 16
        end
    end
end)
#
Userinputservice.InputBegan:Connect(function(input, gameprocessedevent)
    if input.KeyCode == Enum.KeyCode.Q then
        if gameprocessedevent then return end
        if UpDashCooldown == false then
            UpDashCooldown = true
            local DashParticleClone = DashParticle:Clone()
            DashParticleClone.Parent = game.Workspace
            local DashParticlePOS = player.HumanoidRootPart.CFrame.Position - Vector3.new(0, 5, 0)
            DashParticleClone.CFrame = CFrame.new(DashParticlePOS)
            task.spawn(function()
                task.wait(1)
                DashParticleClone:Destroy()
            end)
            task.spawn(function()
                for i = UpDashCooldownTime, 0, -1 do
                    if i ~= 0 then
                        UpDashCooldownGUIText.Text = (i)
                        task.wait(1)
                    else
                        UpDashCooldownGUIText.Text = (" ")
                    end
                end
            end)
            UpDashCooldownGUI.ImageColor3 = Color3.fromRGB(255,0,0)
            Humanoid.Parent.HumanoidRootPart.AssemblyLinearVelocity += Vector3.new(0,300,0)
            wait(UpDashCooldownTime)
            UpDashCooldown = false
            UpDashCooldownGUIText.Text = (" ")
            UpDashCooldownGUI.ImageColor3 = Color3.fromRGB(0,255,0)
        end
    end
end)