I have been working on something that functions as rain whilst inside a building. My main concern is that this local script only works when tested inside of studio. As soon as this is ran in the published version, it doesn’t work. I’ve done some printing testing and it doesn’t fire the .Touched event at all. I’ve looked around for similar situations, but to no avail. Posted below are the snippets affected by the problem. Any help on this issue is appreciated.
local function TouchEndedCheck(v)
if DebounceVariable == false and workspace[player.Name]:WaitForChild("Humanoid").Sit == false then
DebounceVariable = true
if v:GetTouchingParts() ~= nil then
ReverbType.AmbientReverb = Enum.ReverbType.Forest
local TrueTable = 1
for i,g in pairs(v:GetTouchingParts()) do
if g:IsDescendantOf(workspace[player.Name]) == true then
TrueTable = 0
end
end
if player:WaitForChild("RainMuffled").Playing == true and TrueTable == 1 then
print("Part Leaving function")
player:WaitForChild("Rain").Playing = true
player:WaitForChild("RainMuffled").Playing = false
for i,z in pairs(workspace.RainEffects:GetDescendants()) do
if z:IsA("ParticleEmitter") then
z.Enabled = true
end
end
end
end
wait()
DebounceVariable = false
end
end
local function TouchContactCheck(v)
if DebounceVariable2 == false then
DebounceVariable2 = true
print("Part Touching function")
for i,d in pairs (v:GetTouchingParts()) do
if d.Parent.Name == player.Name then
ReverbType.AmbientReverb = Enum.ReverbType.Room
if (player:WaitForChild("Rain").Playing == true or player:WaitForChild("RainMuffled").Playing == true) then
player:WaitForChild("Rain").Playing = false
player:WaitForChild("RainMuffled").Playing = true
for i,z in pairs(workspace.RainEffects:GetDescendants()) do
if z:IsA("ParticleEmitter") then
z.Enabled = false
end
end
end
end
end
wait(.1)
DebounceVariable2 = false
end
end
for i,v in pairs(workspace.IndoorRegions:GetChildren()) do
v.Touched:Connect(function()
wait()
wait()
TouchContactCheck(v)
end)
v.TouchEnded:Connect(function()
wait()
TouchEndedCheck(v)
end)
end