Hi there!
nickibreeki here. Today I’ll be teaching you guys how to create a Footstep Script without using any kind of RemoteEvents, from my perspective!
----------------------------------------------
Requirements
All you need to know is your basic understanding how the script or the program work,
Everything is is noob friendly! which mean no noob is being harm from this…
Welp! that it!
----------------------------------------------
People’s Perception
Most people think that creating footstep sounds is one of the hardest things to do.
Well, most people who are new to scripting or intermediate scripters always say that it’s hard because it wastes server resources by firing the remote every time a player moves.
But we’re not going to do that!
Who would fire the remote every time they walk, right?
----------------------------------------------
Layout/Planning
Whenever you work on something, you need to plan! Planning will make your work get done faster.
I’ll be using a flowchart because it’s very easy to understand just a tree of processes that we’re going to follow.
“Let’s get to the main tutorial already.”
I mean, sure! No more yapping…!
----------------------------------------------
STEP 1 - Create ModuleScript
First of all, we need a “ModuleScript”
To get this or insert this instance, ◨ Right-Click, place your cursor on “⧉ Insert Object…”, and you’ll see the search box in case you couldn’t find the “ModuleScript”
Now, create another “ModuleScript” inside the “ModuleScript” that we just created! We’ll name this “FootstepData” because we’ll store all audio IDs here!
Now, once you pass Step 1 - Create ModuleScript ,
We’ll create the folder to store our audio files!
Same thing ◨ Right-Click on the “ModuleScript” that we just created, find “Folder”.
It can be “Folder”, “Model”, or anything that you can recognize as storing audio!
You did great! Now, in the next step, we’ll program it to make it work!
YES, YOU HEARD THAT RIGHT, THE PROGRAMMING PART!
----------------------------------------------
Step 3 - Get it to work
Alright, let’s review what we’ve done.
- We created 2 ModuleScripts: “Main” and “FootstepData”.
- We created the directory for our Footstep Audio.
If you’ve followed my steps and done everything correctly, then congratulations!!
If it doesn’t look like the image, just make it look like the exact image!
Short Yapping
This part might make you feel like, “I don’t want to do this anymore,” but WAIT!!! A game without any kind of programming section, how is it going to be playable, right? Without programming, the game will just turn into a funny generic obby game instead of an enjoyable one.
FIRST, WE’LL NOT GET INTO THE MAIN PROGRAMMING PART JUST YET.
FIRST, WE NEED TO DO THE GOVERM- I MEAN- YEAH, COLLECT! COLLECTING! AUDIO IDs
Man, every time I mention collecting, why do I have to drag politics into this thread too…
BACK TO THE MAIN TOPIC
Alright, now ◧ Double Click on your “FootstepData (ModuleScript)”. We’ll be adding Audio IDs here.
Once you’re done inserting Sound IDs into the table, we’ll start programming our main system script.
Main System
Once you’re done inserting Sound IDs, you can close the “FootstepData (ModuleScript)” tab.
After closing that tab, ◧ Double Click on your “Main (ModuleScript)”
You’ll be greeted with an empty ModuleScript.
Alright, we’ll import the services that we need to use for this.
This is all we’re using! That’s it!
Now, we’ll create our first function. This function will check/validate the Audio Container.
This function will check and validate whether that folder exists or not. If it doesn’t, it will create one. Alright, now let’s put all the audio in the folder with this function!
Holy grilled! Even my house doesn’t have a grill! What on earth is this function?! Well, this function will create new audio, which will be parented to the Audio Container!
Utility Functions
EDITTED: At the line 61, Please removed MoveDirection ~= Vector3.new() It’s appeared to be my mistake! Thanks @BossSpax
These two functions are utilities that will be used with footsteps!
The first function’s title already explains what it does, so you probably understand it because it’s very essential!
The second function is “MovingCheck”.
This function is used to validate whether the Actor/Character is moving or not by tracking the Humanoid.States and the Humanoid.MoveDirection that the humanoid is moving toward.
Event Functions
Let’s break down each function, step-by-step.
The First Function is onCharacterAdded
First, we’ll get the Humanoid and FootstepDirectory and determine the empty variable “Connection”, which we’ll use to manage the Footstep. Instead of using Humanoid.Running, we’ll use RunService.Heartbeat.
We’ll also register the tick on the Actor/Character, because why not? I’m kind of lazy…
We’ll hook the coroutine with the Connection variable, and inside the coroutine, we have the RunService.Heartbeat and Humanoid.Died triggers. When Humanoid.Died is triggered, the Connection will be terminated.
The Second Function is OnHumanoidRunning
EDITTED: At the line 92, Please change the SetAttribute to GetAttribute!
First, we’ll determine the Velocity, which is returned as a Vector3. We’ll convert it to a single number using Vec3().Magnitude
Then, we’ll measure whether the player is actually moving or not.
When the Actor/Character moves, the value of the Velocity will change, so when we convert it to a single number, we’ll get the speed of the Actor/Character as it rises up to the WalkSpeed value.
When it’s more than 0, we’ll pass another check: the MovingCheck - Function
When the Function returns True, we’ll proceed to get the Humanoid.FloorMaterial, which will return the Enum Item of Enum.Material
We’ll pass the value returned by Humanoid.FloorMaterial and find the Sound that matches the Enum.Material in our FootstepData ModuleScript
When we get the Sound, we’ll trigger the Sound with a randomized volume.
When everything is done, we’ll hook the trigger to the MoveSpeed of the Humanoid.
The next thing is to enable the Footstep, and we’re all done with the first part!
There’s more, but we’ll get into that later!
Register The Events!
Lastly, but very important, we’ll register the events to the client!
After this function, we’re done! But that’s not all…
To make it works, It’s need some small work… !
SERVER-SIDE
we’ll hook the module with the server to create the audio to the audio container!
require(path_to_module):init()
CLIENT-SIDE
Same as how Server done but do the different! the system will be hook with LocalPlayer and Other Player and logging new player too!
require(path_to_module):init()
----------------------------------------------
Thanks for your participating my thread!
Thanks for your interest, I hope you got new knowledge from this thread!
Some word you may not understand my apology because i’m not a english native speaker !
something that you think is missing, You can reply to this thread to helping other people!
Currently there’s only 2 way to support my creation, You can show your support by
-
Donating me with Robux Currency, Do this will help me a little bit on the game development side
Click here to Redirect to game -
Donating with US Currency, This will help so much because i have to funds myself an Education and Support my Medical Treatment
Click here to Redirect to buymeacoffee.com
----------------------------------------------
Thanks @BossSpax for Bug Hunting! I just realize that there’s bunch of mistake appear on this tutorial!
- Yeah!
- It’s Ok
- Kinda Meh
- Nah…
0 voters