Monster Sound DOESNT PLAY!

Hello everyone!
im having an issue with getting the sound to play inside the monster im making,
this code detects his walkspeed and determines rather the sound plays faster or slower or doesnt play at all, anyways…
nothing is playing at all even when he moves, and im not sure what it is, any help? :pray:


local Monster = script.Parent.Parent

local function PlayBackVel()
	if Monster.Humanoid.WalkSpeed > 16 then
		script.stomping.PlaybackSpeed = 1.6
	else
		script.stomping.PlaybackSpeed = 0.8
	end
end

local function StopOrPlay()
	if Monster.Humanoid.MoveDirection.Magnitude < 1 then
		script.stomping:Pause()
	else
		script.stomping.Playing = true
	end
end

while true do
	wait(0.1)
	PlayBackVel()
	StopOrPlay()
end
2 Likes

You don’t mention if the sound is looped or not. As a sanity check, is the Looped property on your Sound enabled?

1 Like

No the looping is not enabled, does it have to?

Are there any errors in the output? I made a similar script and it worked fine. Ensure your studio volume is up, the sound loaded properly and that the sound volume isn’t 0. Also you might want to sanity check the .Magnitude. Just add a print statement before you call StopOrPlay and print out the magnitude

1 Like

some info:
The Volume is at 5 for testing purpose,
i have added the print statement and oh wow, it always says the magnitude = 0
even tho he is like moving.
any idea on why?

MoveDirection doesn’t work on npc’s characters, only players. Use the velocity of a part in the npc instead

if script.Parent.HumanoidRootPart.Velocity.Magnitude >5 then

The number it’s comparing shouldn’t be 0, considering idle animations effect the velocity

1 Like

it worked thank you so much!
im gonna leave the code down for anyone who needs help

local Monster = script.Parent.Parent

local function PlayBackVel()
	if Monster.Humanoid.WalkSpeed > 16 then
		script.Parent.stomping.PlaybackSpeed = 1.6
	else
		script.Parent.stomping.PlaybackSpeed = 0.8
	end
end

local function StopOrPlay()
	if script.Parent.Parent.HumanoidRootPart.Velocity.Magnitude < 1 then
		script.Parent.stomping:Pause()
	else
		script.Parent.stomping.Playing = true
	end
end

while true do
	wait(0.1)
	PlayBackVel()
	StopOrPlay()
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.