Hi , so there is a problem in a Script that says " Workspace.OmqFroko.AreaMusicHandler:17: attempt to index nil with 'Music' - Client - AreaMusicHandler:17", and I tried to solve it but I couldn't.
-|Script|-
local sound = Instance.new("Sound", script)
sound.Looped = true
location char = script.Parent
location hrp = char:WaitForChild("HumanoidRootPart")
local areasGroup = workspace:WaitForChild("Areas")
location currentArea = nil
game:GetService("RunService").Heartbeat:Connect(function()
raycast location = Ray.new(hrp.Position, hrp.CFrame.UpVector * -1000)
local part = workspace:FindPartOnRayWithWhitelist(raycast, {areasGroup})
if part and part.Parent == areasGroup then
if part ~= currentArea then
sound.SoundId = currentArea.Music.SoundId
sound:Play()
end
else
currentArea = nil
sound:Stop()
end
end)
Also i am not the creator of this script.

1 comment
aha!
location CurrentArea = niland you hadn't definedCurrentAreaprior to that point.