You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? Keep it simple and clear!
I’m developing traffic signals using ZonePlus v3.2.0 right now. I control this only one script that exists SeverScriptService. I place parts above crosswalks to detect Player. When traffic turns red, I set parts’ Attributes ‘IsRed’ false to true and then player who inside or touched the part will die.
What is the issue? Include screenshots / videos if possible!
Using ZonePlus v3.2.0 can detect player to using their functions, but cannot find which part (which is container) is triggered by player. Please let me know how can I detect part or Should I use multiple scripts inside each part to detect?
If you are using for loop for creating zone. Isn’t zone will be value?
Something like
for index, value in next, folder:GetChildren() do
local zone = Zone.new(value)
zone.playerEntered:Connect(function()
print(tostring(player.Name) .. "Touched" .. zone)
end)
end
--Services
local replicatedStorage=game:GetService("ReplicatedStorage")
local serverStorage=game:GetService("ServerStorage")
local collectionService=game:GetService("CollectionService")
local players=game:GetService("Players")
--Folder
local dieFolder=replicatedStorage:WaitForChild("Die")
--Modules
local modules=serverStorage:WaitForChild("Modules")
local zoneModule=require(modules.Zone)
--Valuables
local crossTag=collectionService:GetTagged("CrossWalk")
--CrossWalk Function
local crossWalk=zoneModule.new(crossTag)
--Remotes
local dieCrossWalk=dieFolder.DieCrossWalk
for _,cross in ipairs(crossTag) do
local crossWalk=zoneModule.new(cross)
crossWalk.playerEntered:Connect(function(player)
if cross:GetAttribute("IsRed")==true then
local character=player.Character
local humanoid=character.Humanoid
if humanoid then
humanoid.Health=0
dieCrossWalk:FireClient(player)
end
end
end)
cross:GetAttributeChangedSignal("IsRed"):Connect(function()
if cross:GetAttribute("IsRed") then
local partsArray=crossWalk:getParts()
for _, item in pairs(partsArray) do
if item.Name=="FrontVector" then
local statsFolder=item.Parent.Parent:WaitForChild("Stats")
local currentSpeed=statsFolder.CurrentSpeed
local driveSpeed=statsFolder.DriveSpeed
currentSpeed.Value=tostring(driveSpeed.Value)
elseif item.Name=="HumanoidRootPart" then
local character=item.Parent
local humanoid=character.Humanoid
if humanoid then
humanoid.Health=0
dieCrossWalk:FireClient(players:GetPlayerFromCharacter(character))
end
end
end
end
end)
end
Here is my code. I think my code is not efficient so I try to make my code which do not use CollectionService.