so I made a script that detects if the player has a roof on their head but for some reason if I go outside and look at the ground, the rain drop effect disappears or gets disaled for some reason
heres the code
local MapFolder = workspace.MapFolder
local Player = game:GetService("Players").LocalPlayer
local PlayersUI = Player.PlayerGui:FindFirstChild("PlayersUI")
local RainSoundGroup = game:GetService("SoundService"):FindFirstChild("__RainSoundGroup")
local TweenService = game:GetService("TweenService")
local tInfo1 = TweenInfo.new(0.46, Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false)
local RainSoundExit = TweenService:Create(RainSoundGroup.RainSound, tInfo1, {Volume = 0.3})
local VignetteExit = TweenService:Create(PlayersUI.Vignette, tInfo1, {ImageColor3 = Color3.new(0, 0, 0)})
local RainSoundEnter = TweenService:Create(RainSoundGroup:FindFirstChild("RainSound"), tInfo1, {Volume = 0.1})
local VignetteEnter = TweenService:Create(PlayersUI:FindFirstChild("Vignette"), tInfo1, {ImageColor3 = Color3.new(255, 255, 255)})
local RainModule = require(script.Parent:FindFirstChild("RainScript").Rain)
local CurrentCamera = workspace.CurrentCamera
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character:FindFirstChild("Humanoid")
local RoofHitbox = MapFolder.RoofHitbox
EnteredRoof = false
game:GetService("RunService").RenderStepped:Connect(function()
if CurrentCamera.CFrame.Position.Y > RoofHitbox.Position.Y and EnteredRoof == false then
EnteredRoof = true
RainModule:SetVolume(0.1)
VignetteEnter:Play()
script:WaitForChild("DropIsAllowed").Value = false
warn(Player.Name.." Entered The Roof")
elseif CurrentCamera.CFrame.Position.Y < RoofHitbox.Position.Y and EnteredRoof == true then
RainModule:SetVolume(0.3)
VignetteExit:Play()
script:WaitForChild("DropIsAllowed").Value = true
warn(Player.Name.." Left The Roof")
end
end)