I was wondering if there is a way to make it so when the player reaches a certain walk speed it plays a sound? I have an ATST and when the player reaches a certain walkspeed I want it to play the walking sound.
Thank you for your time.
I was wondering if there is a way to make it so when the player reaches a certain walk speed it plays a sound? I have an ATST and when the player reaches a certain walkspeed I want it to play the walking sound.
Thank you for your time.
You could use the Running event of Humanoid, which returns the current speed the Humanoid is traveling at to it's callback. After that, you can just compare the speed it returns with whatever your speed limit is, and play the sound if the condition is met. Example:
-- Get all player character components
local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild("Humanoid")
-- Perhaps the speed they need to reach or exceed to play the sound
local SPEED_ALERT = 50
-- Quick refs
local floor = math.floor
-- Callback to humanoid's Running event
local function playSoundOnSpeed(speed)
speed = floor(speed)
if speed >= SPEED_ALERT then
print("Speed exceeded, playing sound")
end
end
-- Connect function to event
humanoid.Running:Connect(playSoundOnSpeed)
Just a little rough draft of how you could implement this. You'd still need to add the context for which the sound will be playing, and I'm sure there are other variables specific to your situation as well. Just let me know if you have any questions.
This discussion is preserved as it was. New answers, comments, and votes are closed.