So I am making a wand system where a player can enter a zone and use a wand to make something happen, I have the zones in a folder in workspace, they have different names. But when I test it it only detects one zone and not both. Is there any solution to this?
-----variabes-----
local tool = script.Parent
local LocalPlayer = game:GetService("Players").LocalPlayer
local plr = game.Players.LocalPlayer
local soundRegions = workspace.CustomWandSystem:WaitForChild("Zones")
soundRegions = soundRegions:GetChildren()
local soundManagement = {}
local events = script.Parent.Events
local val = script.Parent:WaitForChild("Region")
local Anim = Instance.new("Animation")
Anim.AnimationId = "rbxassetid://11162230312"
local track
----------SETTNGS--------------
---------fucties----------------
---------startup----------
for _,region in pairs(soundRegions) do
local info = {}
local region3 = Region3.new(region.Position-(region.Size/2),region.Position+(region.Size/2))
region.Transparency = 1
region.CanCollide = false
info.Region = region3
info.welkeregion = region
info.debounce = region.deb
table.insert(soundManagement,info)
end
----------acties---------
tool.Activated:Connect(function()
local deb = false
if deb == false then
if val.Value ~= "None" then
print("none")
if game.Workspace.CustomWandSystem:WaitForChild("Zones")[val.Value].deb.Value == false then
print("zone is false")
events.Zonedeb:FireServer(val.Value)
deb = true
print("deb is true")
track = script.Parent.Parent.Humanoid:LoadAnimation(Anim)
track.Priority = Enum.AnimationPriority.Action
track.Looped = false
track:Play()
events.biem:FireServer()
wait(3)
deb = false
end
end
end
end)
------------altijd----------------
game:GetService("RunService").RenderStepped:Connect(function()
for _,soundInfo in pairs(soundManagement) do
local region = soundInfo.Region
local welkeregion = soundInfo.welkeregion
local parts = workspace:FindPartsInRegion3WithWhiteList(region,plr.Character:GetDescendants())
if #parts > 0 then
events.changearea:FireServer(welkeregion.Name)
else
events.changearea:FireServer("None")
end
end
end)