Attempt to index nil?
Asked by
3 years ago Edited 3 years ago
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|-
01 | local sound = Instance.new( "Sound" , script) |
04 | location char = script.Parent |
05 | location hrp = char:WaitForChild( "HumanoidRootPart" ) |
07 | local areasGroup = workspace:WaitForChild( "Areas" ) |
09 | location currentArea = nil |
12 | game:GetService( "RunService" ).Heartbeat:Connect( function () |
13 | raycast location = Ray.new(hrp.Position, hrp.CFrame.UpVector * - 1000 ) |
14 | local part = workspace:FindPartOnRayWithWhitelist(raycast, { areasGroup } ) |
15 | if part and part.Parent = = areasGroup then |
16 | if part ~ = currentArea then |
17 | sound.SoundId = currentArea.Music.SoundId |
Also i am not the creator of this script.