#UserInputService

1 messages · Page 1 of 1 (latest)

bitter nova
#

Im trying to make that when I click SHIFT, the variable isSprinting is gonna be true. If it is already true than its gonna become false. Also it will print those messages. I dont really care about that sprinting mechanic just yet. I just want to make this printing and isSprinting work.

#

Script:

#
local inputservice = game:GetService("UserInputService")
local player = game.Players.LocalPlayer

local isSprinting = false

local function shiftclicked(input, _gameProcessed)
    if input.UserInputType == Enum.KeyCode.LeftShift then
        isSprinting = true
        print("Player has clicked shift and now sprinting is true.")
        
    elseif isSprinting == true then
        if input.UserInputType == Enum.KeyCode.LeftShift then
            isSprinting = false
            print("Player has clicked shift and now sprinting is false.")
        end
    end
end

inputservice.InputBegan:Connect(shiftclicked)
bitter nova
#

Someone please help

edgy ridge
#

local UserInputService = game:GetService("UserInputService")
local player = game.Players.LocalPlayer

local isSprinting = false

local function onInputBegan(input, gameProcessed)
if gameProcessed then return end

if input.KeyCode == Enum.KeyCode.LeftShift then
    isSprinting = not isSprinting
    print("Sprinting is now:", isSprinting)
end

end

UserInputService.InputBegan:Connect(onInputBegan)

#

i think this one works

bitter nova
#

ill try, thanks