How To Add SPRINT in ROBLOX STUDIO with CODE (Beginner Friendly Shift to Sprint Tutorial)

  Рет қаралды 31,584

Chrisandthemike

Chrisandthemike

Күн бұрын

Learn how to script, code, program, and develop a shift to sprint feature to add to your game in Roblox Studio that is compatible with PC, Mobile, and XBOX devices.
Link to place where you can download and see the script: www.roblox.com/games/10662747...
00:00 Intro
00:27 Adding a LocalScript to StarterCharacterScripts
01:10 What we want to accomplish
01:40 Getting necessary Roblox services
02:22 How to get the Roblox Player Character Humanoid
06:33 Writing the Sprint function
08:40 Writing ContextActionService BindAction
11:40 Handling parameters from ContextActionService
17:34 Testing out the sprint feature in-game
18:38 How to add a title to an on-screen button for mobile devices
19:09 Sprint Code Overview
21:20 How to play the game and get the code
#chrisatm #roblox #robloxdev

Пікірлер: 104
@RakinnYT
@RakinnYT Жыл бұрын
This is very helpful! Usually other tutorials just rush things and don’t briefly explain anything. I would be happy to see more of these videos :)
@rare5x
@rare5x Жыл бұрын
As a beginner scripter, I find it very useful that your tutorials are super beginner friendly, and the fact that you explain it so much, it makes it crystal clear what and why you're doing something! Many people that make tutorials make it a short video, expecting us to copy and paste their code, I hope u dont get side-tracked and start doing this bro, well done on the new content! Im loving it so far!
@mastersenseimario
@mastersenseimario Жыл бұрын
I liked how you went through all the steps and explained how to create the Sprint function! I followed along as best I could (with a few mistakes, one being accidentally putting - instead of = a few times 😅), and I was able to succeed in the end! I gotta say, the world of coding is actually really interesting! I can't wait to see the next video!
@144pxl
@144pxl Жыл бұрын
You should make more of these tutorials as they are very helpful for new devs. I also would like to see the old videos back on the channel even though they aren't the same topic as the new ones
@DH9Crow
@DH9Crow Жыл бұрын
Thanks for the video on how to code! I like how it was very detailed, yet very simple to understand. I'm majoring in Computer Science and I believe that this can be a stepping stone for my studies.
@sypherxl9449
@sypherxl9449 Жыл бұрын
Thank you so much Chris. I watched other tutorials on who to do it but I don't get it. But you really clear and makes me understand.
@jlandrgames2221
@jlandrgames2221 Жыл бұрын
This is awesome I didn’t know how to do this but this helps a lot thank you
@matthewp.1484
@matthewp.1484 Жыл бұрын
Thanks for explaining what everything does! makes it easier to learn other things.
@henryparker4089
@henryparker4089 8 ай бұрын
finally a roblox sprint script that isn't overly complicated. It works and I had fun coding it. The part where you go over what the code means at the end was REALLY helpful thank you for doing that (not sarcasm). If you remove or comment out the in the else part around line 15, then some funny stuff happens
@nathanwright1787
@nathanwright1787 Жыл бұрын
Chris , you and your vids will always have a special place in my heart so thank you 😉(: (;
@dabbytheduke8453
@dabbytheduke8453 Жыл бұрын
Welcome back Chris :)
@krazyyyyyyyy
@krazyyyyyyyy Жыл бұрын
ty for this chris have a better day 👍
@SubToDrexyDevy
@SubToDrexyDevy Жыл бұрын
Yo chris i love ur videos so much and i have been trying to make a roblox game so tysm for the ideas
@chameleon3465
@chameleon3465 Жыл бұрын
This will hopefully help if/once I get to developing a Roblox game
@SonsOfFun
@SonsOfFun Жыл бұрын
Glad your back 🙂
@TheChopmama
@TheChopmama Жыл бұрын
yeah i was in one of his videos before he deleted it
@helloworld5539
@helloworld5539 Жыл бұрын
Nice video well explained. 👍👌
@groboggan9535
@groboggan9535 9 ай бұрын
awesome video man!!
@pierre-gillebreton
@pierre-gillebreton Жыл бұрын
Ty so much for this video 🙏
@T-quqn
@T-quqn Жыл бұрын
Its work. Thanks 😊
@MokyYTR
@MokyYTR Жыл бұрын
U where my favorite youtuber
@ItzZake
@ItzZake Жыл бұрын
didn't expect this video from this channel honestly
@agentdoge315
@agentdoge315 Жыл бұрын
I mean it did say change incoming maybe the change was a different type of roblox instead of playing games
@Sun-kg1nh
@Sun-kg1nh Жыл бұрын
What I learned from this video is to don't complain about bugs unless they break the game 👍
@MaraKaiSeok
@MaraKaiSeok Жыл бұрын
Chris has became the 2000 IQ teacher. Btw please make more videos like these....their very helpful
@alvaropenabella9851
@alvaropenabella9851 8 ай бұрын
thank u so much!!!!!
@TinyPlasticLizards
@TinyPlasticLizards Жыл бұрын
Thank you so much
@livyguard3026
@livyguard3026 8 ай бұрын
thank you!
@ShadowPhantomGaming
@ShadowPhantomGaming Жыл бұрын
Cool 😎
@thechesburgerzrfzz808
@thechesburgerzrfzz808 Жыл бұрын
Hey Chris i know this out context from the video. But I had a genuine question, I had saved minecraft series saved from your playlist, and saw it was all gone. Is It private or deleted?
@cyromaniac
@cyromaniac 9 ай бұрын
when i run my code it sprints but when i let go of shift it stays sprinting can you please let me know how to fix this
@Cat_3ater
@Cat_3ater Жыл бұрын
The myth the legend has returned 🙌
@HerbertEnterprises
@HerbertEnterprises Жыл бұрын
Returned as a master coder.
@PeaksLife
@PeaksLife Жыл бұрын
I’m still trying to do it for my Xbox but nothing seems to work? Like I don’t get why? I’m still doing it now seeing if I made some errors but so far it’s just not working for me for Xbox at least
@Effodev
@Effodev Жыл бұрын
How can i modify this so that instead of Shift, double tapping W enables sprint??
@ICEYCOKEwastakenwasalsotaken
@ICEYCOKEwastakenwasalsotaken 19 күн бұрын
bring back your old vids chris please they are my childhood
@brendancalvert2876
@brendancalvert2876 Жыл бұрын
This man used to do Minecraft role plays it’s so sad how time passes so fast 😔
@user-bx2jf3ry4m
@user-bx2jf3ry4m Жыл бұрын
nice
@teejay818
@teejay818 Жыл бұрын
And…. He’s back.
@Thefartkiller6
@Thefartkiller6 10 ай бұрын
I did all of the thing rightly and i dont know how to save it when i try to test it nothing happened can you tell me how
@puppetstudios9723
@puppetstudios9723 Жыл бұрын
dude the old videos with your wife and you i remmember those i loved them i know why she can not do it any more cause of your kids but it least upload the old videos back this is my first day back on this channel and it has change so much the old videos are my childhood man plz for the ogs who gave you support all those years to get you where you are now on youtube do it just bring one back for us :(
@kcnewman1787
@kcnewman1787 4 ай бұрын
chris help! mine isnt working I have the same amount of lines and cant find my mistake
@compontus918
@compontus918 Жыл бұрын
What happened to the old days when you used to play jaikbreak or car crushers 2 :( I miss those videos
@thetwingamer3968
@thetwingamer3968 Күн бұрын
The mobile emulation thing dont work its greyed out in the testing tab and isnt showing in the corner and i have searched it up and nothing there is no information on it other than just them updating it
@BushiX5
@BushiX5 Ай бұрын
thanks, how do i add animation
@DaBreadStick
@DaBreadStick 5 ай бұрын
i dont understand, every script i input was double, triple, quadrouple, quintuple checked and none of it did anything, even the humanoid speed changing
@Jose_40
@Jose_40 Жыл бұрын
He’s back?
@juniorstevens5970
@juniorstevens5970 Жыл бұрын
Hey Can you please comment the Xbox script please its hard to see the screen so i can't read the script to copy it
@keets5936
@keets5936 5 ай бұрын
i miss your old videos chris please add the videos back to the channel if there private i miss my child hood favorite youtuber
@ICEYCOKEwastakenwasalsotaken
@ICEYCOKEwastakenwasalsotaken 19 күн бұрын
why did it not work i did the same code exactly? someone help
@rostopi-scripting1304
@rostopi-scripting1304 9 ай бұрын
For me, it didn't work, built-in AI scripting on Roblox Studio came up with the same ideas, it just didn't work for me for some reason :(
@Nar4ev3r
@Nar4ev3r Жыл бұрын
Where have you been?
@VienCa-mk5pn
@VienCa-mk5pn 9 ай бұрын
=))) Thanks
@b3azeli6htin9
@b3azeli6htin9 Жыл бұрын
Hello Chris
@TheCraziestGamerZ
@TheCraziestGamerZ 4 ай бұрын
i don't know if it is just me that has this problem and I am really happy that it worked out and I am surprised by the amount of effort and skill you put into these videos but i checked, double checked, and triple checked the code and it still didn't work, and I can't sprint
@Balou1
@Balou1 7 күн бұрын
same with me
@Lil.vs.fun_world
@Lil.vs.fun_world 2 ай бұрын
Why doesnt it work?
@_smo0thie
@_smo0thie Жыл бұрын
It’s just don’t work for me and Ik I’m not doing anything wrong.
@Junkmnr_
@Junkmnr_ Жыл бұрын
Hi Chris, I have a question. On the mobile phone screen, my sprint button is mostly inside the jump button, not beside it. Do you know why this is happening or how to relocate my sprint button?.
@Chrisandthemike
@Chrisandthemike Жыл бұрын
To relocate your sprint button you would do: ContextActionService:SetPosition("Sprint", UDim2.new(1,0,1,0)) And you would experiment with the values that have the "1" in them with decimals like "0.9" or "0.95" to get the button where you would like it to go. Think of the 1st value like the X-Axis and the 3rd value like Y-Axis in moving the button on your screen. Then think of the decimal values like a percentage, so "0.75" would be 75% of the screen on the respective axis.
@Junkmnr_
@Junkmnr_ Жыл бұрын
@@Chrisandthemike thanks 👍
@MRCORUPTONROBLOX
@MRCORUPTONROBLOX 10 ай бұрын
or you could ask chat gpt to script it and copy and paste it
@FriedMonkey362
@FriedMonkey362 Жыл бұрын
I already knew some programming, and uve already made my own run scripts but sometimes the scripts wouldn't work at all and give a nil player error Thanks for solving this problem (Or player:playeradded().wait)
@liquidmane4519
@liquidmane4519 Жыл бұрын
I've compare our codes and don't see any difference so what did I do wrong?(I changed the var name to character instead of char) local Players = game:GetService("Players") local ContextActionService= game:GetService("ContextActionService") local player = Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() repeat wait() until character:FindFirstChild("Humanoid") local huamnoid = character.Humanoid local function handleSprint(shouldSprint) if shouldSprint == true then huamnoid.WalkSpeed= 2 * 16 else huamnoid.WalkSpeed = 16 end end local function handleInput (actionName, inputState, inputObject) if actionName "Sprint" then local shouldSprint = false if inputState == Enum.UserInputState.Begin then shouldSprint=true end handleSprint(shouldSprint) end end local function listenInputs() ContextActionService:BindAction("Sprint", handleInput, true, Enum.KeyCode.LeftShift, Enum.KeyCode.ButtonX) ContextActionService:SetTitle("Sprint", "Sprint") end listenInputs()
@richusssss
@richusssss Жыл бұрын
huamnoid
@idktouchgrass
@idktouchgrass 9 ай бұрын
I don't understand what it meant by "19:04:06.699 Localplayer is not a valid member of Players "Players" - Client - LocalScript:4" When I swore I typed it correctly as: local player = Players.LocalPlayer Any help would be nice, thanks for the tut Chris, it was very easy to understand.
@camronandelean3666
@camronandelean3666 9 ай бұрын
is it in StarterCharacterScripts?
@Segull_Man
@Segull_Man 2 ай бұрын
I tried it but it didn't work Edit: nvm I got it working 😃
@iluvvmyles
@iluvvmyles Жыл бұрын
IT DIDNT WORK WHAT DO I DO
@DevTube0
@DevTube0 Жыл бұрын
userinputservice is a thing too.
@IHateMyself-soshouldu
@IHateMyself-soshouldu Жыл бұрын
Please upload all of the Minecraft content to an Archive channel please.
@Dakota3988-s7v
@Dakota3988-s7v Жыл бұрын
Yeet!
@BetoPrinceYT
@BetoPrinceYT 3 ай бұрын
code doesnt work
@IceTeaB
@IceTeaB Жыл бұрын
gee i just need tutorial how to copy script 😳
@deepfriedhamood5699
@deepfriedhamood5699 Жыл бұрын
what happened to all your old content?
@kingdjplays8434
@kingdjplays8434 Жыл бұрын
HII Chris How r u? After long time:)
@isaacVR222
@isaacVR222 9 ай бұрын
help my roblox sayes ContextActionService is not a service name pls help
@isaacVR222
@isaacVR222 9 ай бұрын
now it says Workspace.MyName.Script:5: attempt to index nil with 'Character'
@WarningDrills
@WarningDrills 3 ай бұрын
line 2 is wrong
@neoluis3952
@neoluis3952 8 ай бұрын
W hitbox
@DevTube0
@DevTube0 Жыл бұрын
first comment.
@ombro1862
@ombro1862 Жыл бұрын
is not working for me my script is this: local Players=game:GetService("Players") local ContextActionService = game:GetService("ContextActionService") local player = Players.LocalPlayer local char = player.Character or player.CharacterAdded:Wait() repeat wait() until char:FindFirstChild("Humanoid") local Humanoid = char.Humanoid local function handleSprint(shouldSprint) if shouldSprint == true then Humanoid.WalkSpeed *= 2 else Humanoid.WalkSpeed = 10 end end local function handleInput(actionName, inputState, imputObject) if actionName == "Sprint" then local shouldSprint = false if inputState == Enum.InputState.Begin then shouldSprint = true end handleSprint(shouldSprint) end end local function listenInputs() ContextActionService:BindAction("Sprint", handleInput, true, Enum.KeyCode.LeftShift, Enum.KeyCode.ButtonX) end listenInputs()
@Dolne4
@Dolne4 Жыл бұрын
You need to change the line "if inputState == Enum.InputState.Begin then" to "if inputState == Enum.UserInputState.Begin then". The mistake was forgetting to add in "User" to InputState.
@ombro1862
@ombro1862 Жыл бұрын
@@Dolne4 thank you guy have a great day
@tinylizardgamer751
@tinylizardgamer751 Ай бұрын
It didn't work
@lilcat6299
@lilcat6299 Жыл бұрын
hi
@SizzleSizzling
@SizzleSizzling Жыл бұрын
Haha speed go brrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrrr
@Krizzylys
@Krizzylys Жыл бұрын
I think Chrisandthemike reset the channel and turned into a dev and coding channel instead of a gaming channel. Something might've happened
@draff1107
@draff1107 Жыл бұрын
u think huh
@Wolfbounty
@Wolfbounty Жыл бұрын
How to open Roblox studio
@mastersenseimario
@mastersenseimario Жыл бұрын
First, turn on your PC. Then, find and click an icon that looks like a Blue Roblox logo on your Desktop.
@Wolfbounty
@Wolfbounty Жыл бұрын
@@mastersenseimario I only have a Purple Roblox logo
@nathanwright1787
@nathanwright1787 Жыл бұрын
Go onto Create and Download it then open it ( only works on PC )
@mastersenseimario
@mastersenseimario Жыл бұрын
@@Wolfbounty Well I’ve done all I can do
@sweatynoob1402
@sweatynoob1402 Жыл бұрын
for somereason my sprint isn't working and if I try to go and edit the game it doesn't workso just in case you read this, this is my script local Players = game:GetService("Players") local ContextActionService = game:GetService("ContextActionService") local player = Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() repeat wait() until character:FindFirstChild("humanoid") local humanoid = character.humanoid local function handleSprint(shouldSprint) if shouldSprint == true then humanoid.walkspeed = 2 * 16 else -- if shouldsprint == false then set walkSpeed to default value of 16 humanoid.walkspeed = 16 end end local function handleInput(actionName, inputState, inputObject) if actionName == "sprint" then local shouldSprint = false if inputState == Enum.UserInputState.Begin then shouldSprint = true end handleSprint(shouldSprint) end end local function listenInputs() ContextActionService:BindAction("sprint", handleInput, true, Enum.KeyCode.LeftShift, Enum.KeyCode.ButtonX) end listenInputs()
@Dolne4
@Dolne4 Жыл бұрын
I looked through the code and your mistakes are not putting Capital H in humanoid from local humaoid and from repeat wait() until character:FindFirstChild("humanoid"). Missing the capital letters for every word that is walkspeed. It is supposed to be WalkSpeed. The reason why your code wasn't working was because from the code repeat wait() until character:FindFirstChild("humanoid") It was waiting for something that is named humanoid. The thing the humanoid is named Humanoid with a captial H. Here is the corrected code so that you can see what you did wrong. I hope this helps you. local Players = game:GetService("Players") local ContextActionService = game:GetService("ContextActionService") local player = Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() repeat wait() until character:FindFirstChild("Humanoid") local humanoid = character.Humanoid local function handleSprint(shouldSprint) if shouldSprint == true then humanoid.WalkSpeed = 2 * 16 else -- if shouldsprint == false then set walkSpeed to default value of 16 humanoid.WalkSpeed = 16 end end local function handleInput(actionName, inputState, inputObject) print(actionName) if actionName == "sprint" then local shouldSprint = false if inputState == Enum.UserInputState.Begin then shouldSprint = true end handleSprint(shouldSprint) end end local function listenInputs() ContextActionService:BindAction("sprint", handleInput, true, Enum.KeyCode.LeftShift, Enum.KeyCode.ButtonX) end listenInputs()
@Akunemal610
@Akunemal610 Жыл бұрын
@@Dolne4 man i was with dificulty over capitalized letters tho, i appreciate it
@pierre-gillebreton
@pierre-gillebreton Жыл бұрын
@@Dolne4 man ty so much 🤧🙏
@cynicalstage7047
@cynicalstage7047 Жыл бұрын
What happened to this KZfaqr man
@Jerry_Wjs
@Jerry_Wjs Жыл бұрын
how is ur wife and baby chris?
@josephstalin2191
@josephstalin2191 Жыл бұрын
14th
I Made the Jailbreak Jewelry Store in Roblox Studio
8:39
Chrisandthemike
Рет қаралды 37 М.
What Is The Best AI For Roblox Studio Scripting?
10:42
RoDev
Рет қаралды 419 М.
Cool Items! New Gadgets, Smart Appliances 🌟 By 123 GO! House
00:18
123 GO! HOUSE
Рет қаралды 17 МЛН
Sigma Kid Hair #funny #sigma #comedy
00:33
CRAZY GREAPA
Рет қаралды 35 МЛН
Mom's Unique Approach to Teaching Kids Hygiene #shorts
00:16
Fabiosa Stories
Рет қаралды 31 МЛН
Essential UI Tips & Tricks | Roblox Studio
9:19
Stewiepfing
Рет қаралды 28 М.
Can AI Code Minecraft? Watch ChatGPT Try
8:06
BadGameDev
Рет қаралды 1,2 МЛН
Making a Game in Lua with No Experience
5:52
Goodgis
Рет қаралды 277 М.
Why I Hate Roblox Abilities
11:52
ByteBlox
Рет қаралды 361 М.
DON'T Make a Roblox Game Without Watching This First.
27:20
SmartyRBX
Рет қаралды 502 М.
BEST GUIDE to animating on Roblox for free! [Beginner]
7:36
Pandastroyer
Рет қаралды 266 М.
How pro Roblox developers learnt to script
10:03
AlvinBlox
Рет қаралды 843 М.
2 Python Developers VS $1000
15:04
PolyMars
Рет қаралды 1,8 МЛН
Gosta de 🌟 e 🍿?
0:19
F L U S C O M A N I A
Рет қаралды 3,8 МЛН
Необычное растение! 😱🌿
0:27
Взрывная История
Рет қаралды 2,1 МЛН
ToRung short film: 1🥐 cake costs 1$
0:25
ToRung
Рет қаралды 11 МЛН
ДОМАШНЕЕ ЭСКИМО//ПРОВЕРКА РЕЦЕПТА ТИК ТОК
0:24
ОЛЯ ПЕРЧИК
Рет қаралды 1,7 МЛН