🔊How to ADD music into DIFFRENT AREAS 🔊 | Roblox studio
Thanks for watching! This video is a Roblox Studio Tutorial
Script:
local AreaSounds = Instance.new("Sound", script) - - "Sound" Here put your sound name
AreaSounds.Looped = true
local plr = script.Parent
local Presser = plr:WaitForChild("HumanoidRootPart")
local DifferentAreas = workspace:WaitForChild(" ") - - - - Put here you model name
local CurrentArea = nil
game:GetService("RunService").Heartbeat:Connect(function()
local raycast = Ray.new(Presser.Position, Presser.CFrame.UpVector * -1000)
local part = workspace:FindPartOnRayWithWhitelist(raycast, {DifferentAreas})
if part and part.Parent == DifferentAreas then
if part ~= CurrentArea then
CurrentArea = part
AreaSounds.SoundId = CurrentArea.Sound.SoundId
AreaSounds:Play()
end
else
CurrentArea = nil
AreaSounds:Stop()
end
end)
Twitch: https://www.twitch.tv/the_lovjak
Twitter 🐦: https://twitter.com/ThE_LovJak
Discord: https://discord.gg/bcCFBdZ8dm
Subscribe to JakLov: https://www.youtube.com/channel/UCZYHTvHRCqAvNAaiBJZw0Rg
Other Videos By LovJak
Other Statistics
Roblox Statistics For LovJak
Currently, LovJak has 127,722 views for Roblox across 80 videos. His channel uploaded 9 hours worth of Roblox videos, or 26.34% of the total watchable video on LovJak's YouTube channel.