#Sprint script (formerly called: why doesnt this script work?)
1 messages · Page 1 of 1 (latest)
that’s how it works
what
you see how it's red
red text
red squiggly underline
ok now it should work
** You are now Level 4! **
on both sides
wait
well your function is named onInputStarted
is onInputEnded a thing
this is what it looks like now btw
and you're trying to connect a callback named onInputEnded to the event UserInputService.InputEnded
oh you fixed that
It should probably work
so this is a local script?
yes
there's InputBegan
and where is it?
should probably switch to that
are there any errors
use output
name is lowercase here but it's not red
so you have to be more specific
don't say it "doesn't work"
say it does nothing
or does something you wouldn't expect it to
say what that is
nothing
yes
that's not a keycode
Does it work now
** You are now Level 3! **
no
if you're using leftshift
as a input
yes
I have shiftlock disabled
oop
well
userinputtype
is different
try KeyCode
input.KeyCode
userinputtype is usually for
mouse things
yk
mouse move or lmb rmb blabla
sorry I was doing other stuff
there is no such thing
but I can try inputobject
nope
that wont work
hm
not a screenshot
wdym
send the text
okay, but I wanted to do it myself with help
local UserInputService = game:GetService("UserInputService")
local function onInputStarted(inputObject, processedEvent)
if processedEvent then return end
if inputObject.UserInputType == Enum.KeyCode.LeftShift then
print("Shift key pressed" .. inputObject.KeyCode.Name)
end
end
UserInputService.InputEnded:Connect(onInputStarted)```
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local function onInputStarted(inputObject, processedEvent)
if processedEvent then return end
if inputObject.KeyCode == Enum.KeyCode.LeftShift then
print("Shift key pressed" .. inputObject.KeyCode.Name)
end
end
UserInputService.InputBegan:Connect(onInputStarted)
here you go
switch it I think
you're checking if the UserInputType is a KeyCode
it's never a KeyCode
you have to check the KeyCode property of the InputObject
wait I'm still trying to process allat
** You are now Level 5! **
completely forgot about this
YES
IT WORKS NOW
TYSM
I mean, I still have to change what it does
but its a good start
ywyw
this is what it outputs btw
how do I findfirstchild
I love it when it just does all the work for me
some times it’s not correct though
Ik
why do u need it to print when shift key pressed
you can make it do a sprint
wdym
like when u hold shift it makes u sprint
yes
that was the plan
I also want it to change the animation later
but thats a whole other can of worms
well, its not ass
but I need to make it go back to 16 somehow
I'll try doing the opposite
on ended
alr it works
:D
imma rename the thread
Sprint script (formerly called: why doesnt this script work?)
im also going to make a sprint animation and I'll be back afterwards
okay so I suck at animating
so I just took my walkanim and sped it up
81630182425656
how would I make the script change the anim
load the running animation onto the player's animator. every time the player starts sprinting, do animation:Play(), and every time they stop, do animation:Stop()
probably
idk