Haptic Service (Controller Vibration) - Roblox Advanced Scripting #33 (2025) — Transcript
Full transcript
- 0:00Thanks for stopping by everyone. I'm
- 0:01inside of Mike's Motors because I'm
- 0:03trying to get myself a good car. Now, in
- 0:05order to determine what the best car is
- 0:08that Mike has to offer here, let's just
- 0:10look at the finer details of this one.
- 0:12This car's made looks to be out of
- 0:15cobblestone, which I thought cars are
- 0:17made out of metal, not cobblestone, so
- 0:19this is a little strange and it looks
- 0:21kind of ugly in my opinion. But, this
- 0:23one Oh my god, this looks so good. I
- 0:27might actually get this car. It looks
- 0:28very nice. It looks very nice. All
- 0:30right, Mike, I think I've come to a
- 0:32decision. I want to buy this red car
- 0:34right here.
- 0:35I have some Robux for you.
- 0:37Hopefully this is going to be enough to
- 0:38cover for the car. So, I'm just going to
- 0:39drop this and Okay, well, it's kind of
- 0:42on the ground, but I mean it's yours
- 0:43now.
- 0:44And I'm guessing these are the keys to
- 0:46the car, so I'm just going to swipe
- 0:48these. All right, looks very nice. Looks
- 0:50very nice. All right, I'm about to give
- 0:52this car a spin and I'm going to whip
- 0:53out my controller so I can really feel
- 0:55the rumble. All right, let's go in.
- 0:58Oh yeah. Wait, what happened to my What
- 1:01happened to my hat? Where did it go?
- 1:03That's a little whack, bro. All right,
- 1:06let's just drive on out of here. Oh
- 1:09yeah. Oh yeah. Oh yeah. This car is so
- 1:13nice. This car is so nice. I feel the
- 1:14rumble, too. Like I feel the rumble in
- 1:16my controller, too. Feels really good.
- 1:18Feels really good. But, oh wait, this
- 1:20this car feels a little unstable though.
- 1:23It's like if I if I try to move for a
- 1:25long period of time, it just kind of
- 1:26like rattles in here. Uh maybe I should
- 1:29be concerned about this. I have no idea.
- 1:32Uh
- 1:33Okay, wait, this car does not feel
- 1:35right. This car does not feel right in
- 1:37the slightest. I feel like something's
- 1:38about to break.
- 1:40Wait, what?
- 1:42Wait, my car just exploded.
- 1:45Bro, I got I got scammed, bro.
- 1:49What?
- 1:50All right, let's think about this for a
- 1:51minute. This video's going to be about
- 1:53haptic service, which is a a that allows
- 1:56us to add rumbling and vibrations to our
- 2:00controllers and to our mobile devices
- 2:02whenever we're playing a Roblox game.
- 2:04So, right now, I have my controller
- 2:06connected to this game, so I'm able to
- 2:08play this game with my controller. And
- 2:10while my controller is connected, I can
- 2:12get haptic feedback responses
- 2:15for whatever I decide to add
- 2:17with those things inside of the game.
- 2:19So, some examples that I've made involve
- 2:21jumping and then it provides a haptic
- 2:24feedback on my controller that basically
- 2:26rumbles whenever I jump and whenever I
- 2:28land on the ground. But I also have this
- 2:30shift to sprint system where I hold
- 2:32right trigger and then it makes my
- 2:34character move really fast, but also my
- 2:37controller that's being connected is
- 2:39constantly vibrating. I don't think you
- 2:41can hear this, but yeah, my controller
- 2:43is vibrating
- 2:45constantly until I let go and then it
- 2:47basically just returns just like that.
- 2:49So, this is what I'm going to be
- 2:50teaching you how to add inside of your
- 2:51Roblox game and I hope that you find
- 2:53this tutorial to be helpful. And with
- 2:54that being said, let's go ahead and go
- 2:56straight into the episode. Now that we
- 2:58understand it, let's implement haptic
- 3:00service inside Roblox Studio. But before
- 3:02we begin, I want to mention that due to
- 3:04the nature of this tutorial being about
- 3:07controller vibrations, ideally I would
- 3:09want you to have a physical controller
- 3:11connected to your PC so that we can
- 3:13truly test the vibrations of our
- 3:15controllers once we implement them
- 3:17inside of our game. But if you don't
- 3:19have a physical controller, then there
- 3:20is an alternative and that is through
- 3:22controller emulation. And the whole idea
- 3:24behind controller emulation is that
- 3:27we're we're mapping out controls of a
- 3:29controller onto our keyboard so that we
- 3:32can emulate what it would be like to
- 3:34play on a controller. And as of
- 3:36recording this video, this is a beta
- 3:38feature, but if let's say you were
- 3:39watching this like a year from now, then
- 3:41this is probably out of beta and you can
- 3:43use and you can use this feature
- 3:45normally. But if you are watching this
- 3:46if it's a beta feature, then I'm going
- 3:48to show you how to enable it. So, what
- 3:50What going to do is go to file and then
- 3:52we're going to click on beta features.
- 3:54So, if we scroll down just a little bit,
- 3:56we should find something called gamepad
- 3:59emulator. So, we want to select this,
- 4:01and we want to hit save. So, it's going
- 4:03to ask us to restart studio, in which we
- 4:05are going to hit restart, and then we're
- 4:06just going to wait for this to load back
- 4:09up. All right, so now that we've loaded
- 4:10in, if we go to the test tab, then there
- 4:13should be a new button here under
- 4:15emulation called controllers. So, what
- 4:16we're going to do is click on this, and
- 4:18it's going to show a window down here
- 4:21that shows the mapping of what keys we
- 4:24have to press to emulate these specific
- 4:28buttons that are laid out on this
- 4:30controller. And we can test this out if
- 4:31we hit play.
- 4:33We can basically play the game as if we
- 4:35were playing on a controller, but
- 4:36instead we're just using our keyboard.
- 4:38So, if we want to use WASD, this is
- 4:41going to mimic what the left joystick is
- 4:43going to be like. And if we want to
- 4:45mimic the buttons over here, then we can
- 4:47just use the numbers 7 8 9 and 0 just
- 4:50like so. And this is a really effective
- 4:51emulator if we want to test the game
- 4:53using a controller if we don't have a
- 4:55physical controller. So, I think this
- 4:57would be really helpful for you to use,
- 4:58and with that being said, let's now go
- 5:00and continue with this tutorial. Okay,
- 5:02now let's start scripting haptic
- 5:04service. And the way we're going to do
- 5:05that is we're going to do this on the
- 5:07local side. So, we're going to insert a
- 5:09local script probably inside of, let's
- 5:12say, starter character scripts. So,
- 5:14let's hit the plus sign, and we're going
- 5:16to insert a local script, and we're
- 5:17going to delete the code that's over
- 5:18here. And we're first going to make
- 5:20reference to haptic service by saying
- 5:22local haptic service equals game colon
- 5:25get service haptic service just like
- 5:28this. Now, before we can start utilizing
- 5:31the vibration capabilities of our
- 5:33controller, we first have to check if
- 5:36the device that we plugged in can be
- 5:38vibrated. And if the motor that we're
- 5:40trying to change is also supported with
- 5:43this device as well. I'm going to show
- 5:44you and I'm going to show you both of
- 5:46these things. So, first what we have to
- 5:47do is check if it's vibration supported.
- 5:50So, we're going to say if haptic service
- 5:53{colon}
- 5:54is vibration supported open close
- 5:58parentheses. And this takes in a an enum
- 6:01value of a user input type. And And I'm
- 6:03going to show you what input type we're
- 6:04going to use here. So, we're going to
- 6:06say enum.userinputtype.
- 6:11And because we're testing out a
- 6:12controller, we're going to say gamepad
- 6:14one. So, we're going to hit enter. And
- 6:17then we're going to
- 6:20And if this is vibration supported, then
- 6:22we're just going to make a print
- 6:23statement saying that this device
- 6:26supports vibration just so that we know
- 6:28that this is working. So, what we're
- 6:30going to do is go to the game. We're
- 6:32going to hit test. We're going to enable
- 6:33our controller emulator. And we're going
- 6:35to hit play. So, then what we should see
- 6:37in the output is this device supports
- 6:39vibration, which is what we expected.
- 6:41So, the next thing we need to do is that
- 6:43if we can change specific parts of this
- 6:45controller to be able to vibrate. So,
- 6:46what we're going to do down here is say
- 6:48if haptic service {colon} is motor
- 6:52supported open and close parentheses.
- 6:54First thing we're going to do is add the
- 6:56input type, which is the same thing we
- 6:57did before. So, we're going to say
- 6:59enum.userinputtype.gamepad
- 7:01one. Now, for the second argument, this
- 7:04is what's called a vibration motor. Now,
- 7:07to basically explain these motors, let's
- 7:09go back to the game and I'm going to
- 7:11pull up the controller emulator again.
- 7:13So, based on the way this controller
- 7:15looks, there's multiple motors which are
- 7:18basically points inside of the
- 7:20controller that is allowed to be
- 7:22vibrated. So, there can be a certain
- 7:25section that basically makes up a
- 7:26majority of the controller called large,
- 7:28and we can make that motor vibrate. Or
- 7:30if you want to make a specific part of
- 7:32the controller, like let's say this
- 7:33right trigger area to vibrate, then we
- 7:35can do that as well. There are specific
- 7:37parts of this controller that we can
- 7:39vibrate, and these are essentially our
- 7:42motor points.
- 7:43So, that's essentially what we're trying
- 7:45to change here, and this is the function
- 7:47we're going to use to detect if this
- 7:49motor is supported with the controller
- 7:51that we have plugged in. So, what we're
- 7:53going to do is say enum.vibrationmotor,
- 7:57and the most common ones are usually
- 7:59large and small. So, in this case, we're
- 8:02going to test out large, and then we're
- 8:04going to say then, just like so. And so,
- 8:06this is going to check if it supports
- 8:07this motor. So, we're going to print
- 8:09saying uh large motor is supported, just
- 8:12like this. We're going to go and enable
- 8:15the controller again, and then we're
- 8:16going to hit play. So, then what we
- 8:18should see in the output is that this is
- 8:20also uh supported with a large motor, so
- 8:23that this is the motor we're going to
- 8:25vibrate uh through our controller.
- 8:28And so, I hope so far this is making
- 8:29sense to you. So, now that we know that
- 8:31this vibration motor is supported, we
- 8:33can now create controller vibrations
- 8:35using this function that I'm going to
- 8:36show you right now. So, we're going to
- 8:37drop two lines here, and what we're
- 8:39going to do is say
- 8:40hapticservice:setmotor,
- 8:44open and close parentheses just like
- 8:45this. And what we're going to do is pass
- 8:47in the user input type, so this is going
- 8:49to be enum.userinputtype.gamepad1,
- 8:53and then we're going to say uh
- 8:55enum.vibrationmotor.large,
- 8:58and finally, this takes in one more
- 9:00parameter, which is going to be the
- 9:02value of the vibration that we want to
- 9:05set. So, it's a value between zero and
- 9:07one. So, zero meaning that the vibration
- 9:10is off, and then one meaning that the
- 9:12vibration is turned on at its max. But,
- 9:14we can also set values in between zero
- 9:16and one as well. So, in this case, what
- 9:18I'm going to do is set this to one, and
- 9:20basically, what this does is it's going
- 9:22to switch the motor from zero to one,
- 9:25but it's constantly going to do this
- 9:26until we turn it off. And so, what we're
- 9:28going to do down here is put a task.wait
- 9:31statement for about, let's say, 2
- 9:33seconds, and then we're basically just
- 9:35going to copy this line, and we're going
- 9:37to paste it down here, and we're just
- 9:39going to set this back to zero. So, now
- 9:41what should happen is I'm also going to
- 9:42write some print statements here saying
- 9:44start motor, and then we're going to
- 9:47write another print statement here
- 9:48saying stop motor, just so that we can
- 9:50see that it's working inside of the
- 9:51script. So, if we go into the game,
- 9:53enable our controller, and then hit
- 9:55play, then what we should see in the
- 9:57output is we're starting the motor, and
- 10:00then after 2 seconds, it stopped the
- 10:01motor. Now, you can't really see this
- 10:03inside of the game if you don't have
- 10:05have a physical controller, but I have a
- 10:07physical controller connected inside of
- 10:09the game, and so I was able to feel the
- 10:12vibration coming out of my physical
- 10:14controller. But, you can trust me on
- 10:16this, it it is working.
- 10:18Now, I do want to add a bit of a side
- 10:19note to this and say that device
- 10:21vibration also works on mobile devices,
- 10:24but we're not going to be using the
- 10:25gamepad, but instead we're going to be
- 10:27using a different user input type. So,
- 10:29I'm going to show you what this looks
- 10:30like down here really quick. First thing
- 10:32we have to do is check if it's vibration
- 10:34supported, so we're going to say if
- 10:36haptic service colon is vibration
- 10:38supported, and what we're going to say
- 10:40here for the user input type is say
- 10:42touch, just like this. Touch is
- 10:44basically any device that is like a
- 10:47phone or a tablet that has a touch
- 10:50capability to them.
- 10:51So, if this is true, and what we're
- 10:53going to do here is basically say haptic
- 10:55service colon set motor, and then we're
- 10:57going to say enum.userinputtype.touch,
- 11:02and we can use the same motor we did up
- 11:04here with large. We can say
- 11:06enum.vibrationmotor.large,
- 11:09and then we can set this to one. And so,
- 11:10if you were to test this on a touch
- 11:12device like a phone or a tablet, then
- 11:15this should make the device vibrate as
- 11:17well. And this is not restricted to just
- 11:19controllers, but that's primarily what
- 11:21we're going to be doing for this
- 11:22tutorial. So, this is like a little
- 11:24thing I wanted to add on to here in case
- 11:26you wanted to do this for your touch
- 11:28devices as well. Now, it would be
- 11:30problematic to set off a bunch of motors
- 11:33and then turn them off later. So, it's
- 11:35like if I were to have large and small
- 11:38be turned on and then large and small be
- 11:40turned off, then we would have to
- 11:42manually turn on and turn off these
- 11:44different motors. Which is why it would
- 11:47be better if we had our own controller
- 11:49module script to help us regulate these
- 11:54motors that we set off and whenever we
- 11:56don't need to have these motors on
- 11:58anymore, then we can just have simple
- 12:00function to just turn them off. And in
- 12:01my opinion, this would be a more
- 12:03efficient way to handle our controller
- 12:06motors rather than just turning them on
- 12:07and off manually. So, here's what we're
- 12:09going to do. We're going to go to the
- 12:10game and we're going to insert a module
- 12:13script inside of replicated storage just
- 12:16like this and we're going to call this
- 12:18haptic controller just like this. And
- 12:21we're also going to name the module
- 12:23haptic controller just like this. And
- 12:27the first thing we're going to do is go
- 12:29to our local script copy our reference
- 12:31of the haptic service and we're going to
- 12:33do that up here. Now, there's going to
- 12:34be three functions that we're going to
- 12:36add to this haptic controller. The first
- 12:39thing is to check if this is motor
- 12:40supported and then two more functions
- 12:42are going to be related to starting the
- 12:44motor and then stopping the motor. So,
- 12:46we're going to say function haptic
- 12:49controller.
- 12:50dot is motor supported open and close
- 12:54parentheses and we're going to pass in
- 12:56two arguments here. So, the first thing
- 12:57is going to be the input type and then
- 13:00the vibration motor just like this and
- 13:02we're going to hit enter. And then what
- 13:04we're going to do is return haptic
- 13:06service colon is motor supported and
- 13:10we're just going to pass in the input
- 13:12type and the vibration motor just like
- 13:14this.
- 13:15And now we're going to add two more
- 13:16functions. We're going to say function
- 13:18haptic enter
- 13:22and then we're going to have one more
- 13:24for stop just like this. Now, what we're
- 13:28going to pass into both of these
- 13:29functions are the input type and the
- 13:33vibration motor, just like this. So,
- 13:36we're going to copy this and paste it
- 13:37down here. Now, for the stop function,
- 13:39this should be pretty easy. It's just
- 13:41one line. And basically, what we're
- 13:42going to do is just say haptic service,
- 13:46colon, set motor, open close
- 13:48parentheses. We're going to pass in the
- 13:50input type and we're going to pass in
- 13:52the vibration motor. And we're just
- 13:53simply going to set this to zero,
- 13:55because that's essentially what we're
- 13:56doing when we're stopping a motor from
- 13:58vibrating. And we're just setting the
- 14:00value of it to zero. And the same
- 14:01principle can basically be said about
- 14:04our start function as well, except
- 14:06instead of a constant value of zero,
- 14:08we're going to set this to an intensity
- 14:10variable that we're going We're going to
- 14:12set this to an intensity parameter,
- 14:14which is what we're going to add for our
- 14:15third parameter here. We're just going
- 14:17to say intensity. And then finally,
- 14:19we're going to add in one more
- 14:21parameter, which is going to be the
- 14:23duration of this vibration. So, we're
- 14:25going to replace this zero with the
- 14:27intensity. And now, uh the final thing
- 14:30we need to do for the start function is
- 14:33to give a duration as to how long we
- 14:35want this vibration to be set for. So,
- 14:38the way we're going to structure it is
- 14:39like this. We're going to drop two lines
- 14:41and we're going to put in a task. delay
- 14:45for however long the duration is. And
- 14:47then we're going to create a new
- 14:48function for this um task.delay function
- 14:51here. And so, basically, what we're
- 14:53going to do is simply just say haptic
- 14:55controller.stop, open close parentheses.
- 14:57And we're going to pass in the input
- 14:59type and the vibration motor, simply
- 15:01just like this. Now, the reason we're
- 15:03using task.delay is because we can have
- 15:06multiple We can have multiple motors be
- 15:09set off at the same time. So, we don't
- 15:12want the function to wait for a single
- 15:15motor to finish first before activating
- 15:17another one, which is why we're going to
- 15:19use a task.delay, because that allows us
- 15:21to activate multiple motors if we wanted
- 15:24to be able to do that.
- 15:25So, this is our basic function here, but
- 15:27if let's say we wanted to have an
- 15:29indefinite duration, meaning that if we
- 15:32want to start this vibration, but then
- 15:34we don't want it to stop until we
- 15:36specifically say that we want to stop
- 15:38this vibration, then we can do that
- 15:40using a value. Now, what is this value?
- 15:42Well, we can basically set it to be
- 15:43whatever value we want as long as it's
- 15:45not zero or anything greater than zero.
- 15:48So, let's make the value -1 in this
- 15:50case. So, what we're going to do is say,
- 15:52if duration is not equal to -1, then
- 15:57we're just going to take everything we
- 15:59have here and paste inside of here.
- 16:01Because if the value is -1, then we
- 16:03don't want to have a duration. But, if
- 16:06it's anything that's not -1, then we're
- 16:09going to add in a task.delay duration to
- 16:11this and then we're going to stop the
- 16:13controller. I hope that this has made
- 16:15sense to you. If it hasn't, then you can
- 16:16rewatch this part so that you can
- 16:18understand some of the parts that you
- 16:19weren't able to understand the first
- 16:21time, but generally, this is how our
- 16:24haptic controller function works. And
- 16:26now, let's implement this. Okay, so
- 16:27inside of our local script, we're first
- 16:29going to make reference to our haptic
- 16:31controller module by saying, local
- 16:33haptic controller equals require
- 16:37game.replicatedstorage:WaitForChild
- 16:40haptic controller just like this. Um
- 16:43we're also going to drop some lines down
- 16:45here at the bottom. And what we're going
- 16:46to do is say, if hapticcontroller.
- 16:50IsMotorSupported.
- 16:52And what we're going to throw in here is
- 16:53an Enum.UserInputType
- 16:55of Gamepad1 and then a vibration motor
- 16:59of, let's say, small in this case. Then
- 17:03we're going to make the small vibration
- 17:05motor activate by saying,
- 17:08hapticcontroller.Start,
- 17:11open close parentheses. And we're going
- 17:12to pass in the four arguments by saying,
- 17:14Enum.UserInputType.Gamepad1 and then
- 17:18enum.vibrationmotor.small
- 17:20and then we're going to add an intensity
- 17:22from 0 to 1. So, let's say 0.5 in this
- 17:25case. And then for the duration, well,
- 17:27we can set a duration to however many
- 17:29seconds we want. Let's say 2 seconds and
- 17:32this is automatically going to stop
- 17:34after 2 seconds. But let's say we wanted
- 17:36to have an indefinite time um for this
- 17:39function, we're just going to say -1 and
- 17:41so we would have to manually stop this
- 17:43ourselves. So, what we're going to do is
- 17:45let's say we have a task that wait here
- 17:47for about uh 2 seconds and then we're
- 17:50going to say haptic controller.stop
- 17:53open close parentheses and we're going
- 17:55to pass in the uh user input type. We
- 17:58can just copy this and paste it here.
- 18:00And then for the vibration motor, we can
- 18:02just copy this and paste it inside of
- 18:04here. And that basically stops it. So,
- 18:07this is the equivalent of this right
- 18:11here. So, if we start it, it's going to
- 18:12go for 2 seconds and then it's going to
- 18:14automatically stop within just one line.
- 18:17But uh we can essentially do the same
- 18:19thing just by having an indefinite
- 18:22period of time and so we're going to
- 18:23manually stop this vibration motor after
- 18:252 seconds have passed inside of our
- 18:27local script. And I hope that this has
- 18:30made sense to you. So, for today's
- 18:31challenge, I want you to create this
- 18:33shift to sprint system using the
- 18:35controller's right trigger to activate
- 18:38it. Now, one thing that I want you to do
- 18:40with this challenge is use the haptic
- 18:42controller uh module scripts that we
- 18:45created to add vibrations to our
- 18:48controller device when we are sprinting.
- 18:51So, as you can see in the output, uh
- 18:53there is a start vibration print
- 18:55statement and then there's an end
- 18:56vibration print statement. So, once we
- 18:58hold down right trigger, it's going to
- 19:00make our character sprint, but it's also
- 19:02going to start the vibration of our
- 19:05controller. And it doesn't matter which
- 19:07vibration motor you use um as long as
- 19:09you can see that the vibration is
- 19:10working. You can use large, you can use
- 19:12small, it doesn't really matter too
- 19:13much, but as long as you're holding down
- 19:15right trigger, then it's going to start
- 19:17the vibration and it's not going to stop
- 19:20until you let go the vibration. So,
- 19:22that's essentially my challenge for you
- 19:24for this episode. Go ahead and give it a
- 19:25try and once you think you have
- 19:27something going, then we're going to
- 19:29come back and script this ourselves. So,
- 19:31I will see you in just a little bit.
- 19:33Okay, so let's go back to our local
- 19:34script and we're going to comment out a
- 19:36couple of things. So, we're going to
- 19:38comment out everything that's up here
- 19:40and we're also going to comment out
- 19:41everything that is inside of here as
- 19:43well. So, all we have are the two
- 19:45references for Haptic Service and Haptic
- 19:47Controller. And we now need to make
- 19:49reference to more things in order for us
- 19:51to make this challenge work. And the
- 19:53first thing we need to do is make
- 19:54reference to User Input Service. So, up
- 19:56here we're going to say local User Input
- 19:59Service equals game colon get service
- 20:02User Input Service. And we're also going
- 20:04to need to make reference to our
- 20:05character by saying local character
- 20:07equals script.parent because this is
- 20:10located inside of Starter Character
- 20:11Scripts and we're going to locate the
- 20:13humanoid as well by saying local
- 20:15humanoid equals character wait for child
- 20:18humanoid just like this. So, now we have
- 20:21all of our references that we need. So,
- 20:22now we're going to use two functions
- 20:24from User Input Service. We're going to
- 20:26use input began and input ended. So,
- 20:28we're going to say User Input
- 20:30Service.Input Began colon connect
- 20:33function open and close parentheses.
- 20:35This takes in an input parameter and
- 20:37then we're going to hit enter.
- 20:39And then we're basically going to do the
- 20:40same thing, copy and paste it down here,
- 20:42but instead say input ended just like
- 20:45this. So, we first need to check if the
- 20:48input type is a gamepad. So, what we're
- 20:50going to do is say if
- 20:52input.UserInputType
- 20:55equals Enum.UserInputType.Gamepad1
- 20:59just like this,
- 21:00then we're going to check if the key
- 21:03code of the input matches the right
- 21:06trigger of our controller. So, what
- 21:08we're going to do is say if
- 21:10input.keycode
- 21:12equals enum.keycode.keycode.button
- 21:18R2.
- 21:20So, R2 is basically the right trigger of
- 21:23our controller. And so, that's basically
- 21:25how we represent it as a keycode, it's
- 21:27called button R2.
- 21:29So, inside of here, we're going to use
- 21:31one of the motors of our controller to
- 21:34make it vibrate using haptic controller.
- 21:36But, we need to do one more check and
- 21:38that is to check if it's motor
- 21:39supported. So, what we're going to do is
- 21:41say
- 21:42if haptic controller.is
- 21:45motor supported, we're going to throw in
- 21:47the input type of gamepad one, and we're
- 21:50also going to put the vibration motor
- 21:52of, let's say, small in this case. So,
- 21:56once we have all these checks, we can
- 21:57finally start vibrating the controller.
- 21:59So, what we're going to do is say haptic
- 22:01controller.start,
- 22:03and then we're just going to throw in
- 22:06our user input type and our vibration
- 22:08motor as the first two parameters, and
- 22:11then we're going to set the intensity of
- 22:12this to, let's say, one, and then we're
- 22:15going to set the duration to -1. Because
- 22:17what we want to do is hold down the
- 22:19controller for as long as possible, and
- 22:22then let go to then stop the vibration.
- 22:24So, that's why this is going to run an
- 22:26indefinite period of time.
- 22:28So, once we do this, then another thing
- 22:30we have to do is set the speed of our
- 22:32character's humanoid to be something
- 22:34larger. Um so, what we're going to do is
- 22:36say humanoid.walk speed equals, let's
- 22:39say, 48 because 16 is the default. And
- 22:42then we're going to make a print
- 22:43statement here saying that um we have
- 22:45started the uh vibration of our
- 22:48controller. So, now that we have this
- 22:51taken care of, we can basically copy the
- 22:53same thing and paste it down here um for
- 22:56our input ended. So, we're first going
- 22:58to check if we have a gamepad as our
- 23:00input type, and we're going to check if
- 23:01this was the button R2 key code that
- 23:04we're using as input.
- 23:06And then we check if it's motor
- 23:07supported, then we're going to replace
- 23:10this with stop instead of start. And we
- 23:13don't need the third and fourth
- 23:15parameter here uh if we're using the
- 23:17stop function. And we're also going to
- 23:19change the walk speed back to 16, and
- 23:21we're going to print stop vibration. And
- 23:24this is essentially how we use our
- 23:27haptic controller um
- 23:29module scripts that we created um for an
- 23:32example such as this. So now,
- 23:34if we go into the game, enable our
- 23:36controller emulator, and hit play, then
- 23:39what we should see is we can run around
- 23:42just like normal, but then once we hit
- 23:44right trigger, so if we hold P, then
- 23:48it's going to start the vibration of our
- 23:50controller, and it's also going to make
- 23:52our character move really fast. But then
- 23:54once we let go, then it's going to stop
- 23:56the vibration, and it's going to make
- 23:58our character walk in normal speed. And
- 23:59once again, um
- 24:01you can have my word on this, but my
- 24:03physical controller is vibrating um when
- 24:06when I do press um right trigger. So,
- 24:09this is basically how haptic service
- 24:11works, and I hope that you found this
- 24:13video to be extremely informative. So,
- 24:15that's pretty much going to be it for
- 24:16this episode on haptic service. If you
- 24:18found this video to be extremely
- 24:19informative, then I encourage you to
- 24:21leave a like on this video, and also
- 24:23subscribe to the channel if you haven't
- 24:25already. It would mean so much to me. Um
- 24:27and I would also like to give a
- 24:28shout-out to all of my Patreon members
- 24:30for supporting the work that I do. Um
- 24:32their contribution definitely motivates
- 24:33me to continue doing the work that I put
- 24:36out for this channel uh for you guys to
- 24:38watch. So, I'm very grateful for that.
- 24:39Please check out all of my other content
- 24:41that I have on this channel relating to
- 24:43other advanced scripting topics that you
- 24:44might find interesting. I will leave a
- 24:46link to context action service, which is
- 24:48basically creating mobile buttons for
- 24:50your game uh if you're interested in
- 24:52adding mobile support for your Roblox
- 24:53game, which I'm going to leave the link
- 24:55for you right here to watch. So, go
- 24:57ahead and watch that if you haven't
- 24:58already. With that being said, I will
- 25:00see you in the next episode.
- 25:03Take care.
About this transcript
This page contains the full transcript of Haptic Service (Controller Vibration) - Roblox Advanced Scripting #33 (2025) by BrawlDev, generated from the public captions YouTube serves with the video. The transcript has 4,907 words across 705 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.
What you can do with it
Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.
Free YouTube transcript tool
YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.