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.
First things, workspace:FindPartOnRayWithWhitelist()
is deprecated.
Why are you spacing your variables? Also, make the variables local?
And currentArea is always nil since you've never changed the value of currentArea and that's not a variable.
Can you explain what you're doing? This script is so broken.
are you sure CurrentArea.Music
actually exists? that error usually occurs when Studio is trying to find something when that things parent does not exist.