#Area Music Part Problem

1 messages · Page 1 of 1 (latest)

clear schooner
#

I have a problem where a certain area of my part will not play music, I don't know if it's the numbers, the math, or somethin... I'm new and I'm tryna work my way through it allevilcat

#

'''lua
local Players = game:GetService("Players")
local runService = game:GetService("RunService")
local soundService = game:GetService("SoundService")

local Players = Players.LocalPlayer
local character = Players.Character or Players.CharacterAdded:Wait()

local part = script.Parent

local region = Region3.new(part.Position - (part.Size / 2), part.Position + (part.Size / 2))

local music = soundService:WaitForChild("AreaMusic"):WaitForChild("GrassRegion")

local inRegion = false

local function RenderStepped()
inRegion = false

local params = OverlapParams.new()
params.FilterType = Enum.RaycastFilterType.Include
params.FilterDescendantsInstances = {character}

local parts = workspace:GetPartBoundsInBox(region.CFrame, region.Size, params)

for _, v in parts do
    if v:IsDescendantOf(character) then
        inRegion = true
        break
    else
        continue
    end
end

if inRegion then
    if not music.IsPlaying then
        music:Play()
    end
else
    music:Stop()
end

end

runService.RenderStepped:Connect(RenderStepped)

#

forgot to send the code teehee

neat imp
#

Region doesnt have .cframe or .size i think