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

How to turn off local script from StarterCharacterScripts when you falling down?

Asked by 1 year ago
Edited 1 year ago

I want to make this script not working when the player is falling and when you landed, it will work:

local leaderstats = game.Players.LocalPlayer.leaderstats
local jumps = leaderstats.Points

--|| SERVICES ||--
local camera = game.Workspace.CurrentCamera
local random = math.random(5000, 10000)
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SlideSFX = Instance.new("Sound")
SlideSFX.Parent = script.Parent.HumanoidRootPart
SlideSFX.MaxDistance = 50
SlideSFX.MinDistance = 10
SlideSFX.SoundId = "rbxassetid://6429226498"
SlideSFX.Volume = 1.5
SlideSFX.Name = "SlideSFX"

local Character = script.Parent

local Humanoid = Character:WaitForChild("Humanoid")

local Slide = Humanoid:LoadAnimation(script:WaitForChild("Animation"))

local Properties = {
    Velocity = 300,
    Duration = .10,
    Keybind = Enum.KeyCode.C,
    LastSlide = tick(),
    Cooldown = 1,
}


UserInputService.InputBegan:Connect(function(Input, GameProcessedEvent)
        if Input.KeyCode == Properties.Keybind and Humanoid.Jump == false then

        if tick() - Properties.LastSlide >= Properties.Cooldown then
            Properties.LastSlide = tick()

            Slide:Play()
            SlideSFX:Play() 
            jumps.Value += math.random(3,5)


            local BodyVelocity = Instance.new("BodyVelocity")
            BodyVelocity.MaxForce = Vector3.new(1,1,1) * random
            BodyVelocity.Velocity = Character.HumanoidRootPart.CFrame.LookVector * Properties.Velocity
            BodyVelocity.Parent = Character.HumanoidRootPart

            wait(Properties.Duration)
            BodyVelocity:Destroy()
        end
    end
end)

Answer this question