Hey there, i'm trying to make a slime but i have no scripting knowledge so i came here to get help.
How do i make a sound occur while a player walks onto a specific part? I want the sound to loop, but when the character stops walking i want the sound to stop. How do i do it?
u basically need first a function look `` local function sound() game.soundservice.oof.playing = true
end
game.workspace.part.touched:connect(function name)
game.workspace.part.touched:connect(sound)
local music = path to music here game.Workspace. put your part's name here .Touched:Connect(function() music.Playing = true music.Looped = true end game.Workspace.part name here.TouchEnded:Connect(function() music.Playing = false music.Looped = false end)
This will only play the sound if they are actively walking, and is scripted as if it were inside the part.
local sound = script.Parent:WaitForChild("Sound") sound.Looped = true local deb = false script.Parent.Touched:Connect(function(hit) -- detect touch if deb == false then deb = true local hum = hit.Parent:FindFirstChild("Humanoid") -- get needed parts and make sure this is a player local plr = game.Players:GetPlayerFromCharacter(hit) if hum and plr then if hum.MoveDirection.Magnitude > 0 then -- if they are walking sound:Play() repeat wait() until hum.MoveDirection.Magnitude == 0 -- stop the script until they stop walking sound:Stop() end end deb = false end end)