How can I play different Ambiant sounds when the player is inside or outside?

How can I play different Ambiant sounds when the player is inside or outside?

Do a raycast above the player’s head to check if they are under cover or out of cover.

Use the template i made here.

local player = game.Players.LocalPlayer
local character = player.Character
local head = character:WaitForChild("Head")

local ray = Ray.new(head.Position, head.CFrame.lookVector * 100)
local hit, pos = workspace:Raycast(ray.Origin, ray.Direction)

if hit and hit.Parent:IsA("Model") then
    print("Player is inside a building!")
end

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.