I have a script that changes a players lighting and sound effect depending on the region they’re in. I am trying to add a text that depending on the region the player is in the textlabels text will change. the code works, however it only works on 3 out of the 4 regions there is. Anybody help me? Also, I am using ZonePlus
-- This constructs a zone based upon a group of parts in Workspace and listens for when a player enters and exits this group
-- There are also the ``zone.localPlayerEntered`` and ``zone.localPlayerExited`` events for when you wish to listen to only the local player on the client
local Sounds = script.Parent.SoundRegions
local Lighting = game:GetService("Lighting")
local ColorCorrection = Lighting:WaitForChild("ColorCorrection")
local RegionTextGui = script:WaitForChild("RegionText")
local DefaultClockTime = 14
local TweenService = game:GetService("TweenService")
local tweenInfo = TweenInfo.new(0.5, Enum.EasingStyle.Sine,Enum.EasingDirection.Out,0,false,0)
local Zone = require(game:GetService("ReplicatedStorage").Zone)
local ZoneController = require(game:GetService("ReplicatedStorage").Zone.ZoneController)
local arrayContainer = {
workspace.SoundsRegions.DesertArea,
workspace.SoundsRegions.GrassArea,
workspace.SoundsRegions.SnowArea,
workspace.SoundsRegions.TropicalArea,
workspace.SoundsRegions.VoidArea
}
for _, zone_part in pairs(arrayContainer) do
local ambient_zone = Zone.new(zone_part)
ambient_zone.localPlayerEntered:Connect(function()
Sounds[zone_part.Name]:Play()
local TweenStartAudio = TweenService:Create(Sounds[zone_part.Name],tweenInfo,{Volume = 0.2})
TweenStartAudio:Play()
if zone_part.Name == "GrassArea" then
local TweenLighting = TweenService:Create(Lighting, tweenInfo, {ClockTime = DefaultClockTime})
local TweenColor = TweenService:Create(ColorCorrection, tweenInfo, {TintColor = Color3.new(1, 1, 1)})
RegionTextGui:WaitForChild("TextLabel").Text = "Grasslands"
TweenColor:Play()
TweenLighting:Play()
end
if zone_part.Name == "DesertArea" then
local TweenColor = TweenService:Create(ColorCorrection, tweenInfo, {TintColor = Color3.new(0.972549, 1, 0.666667)})
local TweenLighting = TweenService:Create(Lighting, tweenInfo, {ClockTime = DefaultClockTime})
RegionTextGui:WaitForChild("TextLabel").Text = "Desert"
TweenColor:Play()
TweenLighting:Play()
end
if zone_part.Name == "SnowArea" then
local TweenColor = TweenService:Create(ColorCorrection, tweenInfo, {TintColor = Color3.new(0.443137, 0.443137, 0.443137)})
local TweenLighting = TweenService:Create(Lighting, tweenInfo, {ClockTime = 8})
RegionTextGui:WaitForChild("TextLabel").Text = "Snow"
TweenColor:Play()
TweenLighting:Play()
end
if zone_part.Name == "TropicalArea" then
local TweenColor = TweenService:Create(ColorCorrection, tweenInfo, {TintColor = Color3.new(0.607843, 1, 1)})
local TweenLighting = TweenService:Create(Lighting, tweenInfo, {ClockTime = DefaultClockTime})
RegionTextGui:WaitForChild("TextLabel").Text = "Tropical"
TweenColor:Play()
TweenLighting:Play()
end
if zone_part.Name == "VoidArea" then
local TweenColor = TweenService:Create(ColorCorrection, tweenInfo, {TintColor = Color3.new(1, 1, 1)})
local TweenLighting = TweenService:Create(Lighting, tweenInfo, {ClockTime = DefaultClockTime})
RegionTextGui:WaitForChild("TextLabel").Text = "???"
TweenColor:Play()
TweenLighting:Play()
end
end)
ambient_zone.localPlayerExited:Connect(function()
local TweenStopAudio = TweenService:Create(Sounds[zone_part.Name],tweenInfo,{Volume = 0})
TweenStopAudio:Play()
Sounds[zone_part.Name]:Stop()
end)
end
ZoneController.setGroup("SoundRegions", {
onlyEnterOnceExitedAll = true;
})