New: Nitro Boost our Discord server and receive full donation perks here on the website! Join the Scripting Helpers Discord Server to learn more! You can also Support on Patreon as always.
Still have questions? Join our Discord server and get real time help.
-1

# Any way I can set a debouce?

K so I have a payload region/zone, and if u see, I have print (part.Parent.Name, "Found in the Zone!") But when I go into the region/zone, I get (MyRobloxName Found in the Zone! (x14) and then it goes up and up each sec. Any way I can get it to only find the upperTorso instead of the Humanoid or if I can just set a debounce so those numbers go x1 instead of x14?

(Note: There's no problem with the script)

local payload = game.Workspace.Payload
local inZone = game.Workspace.InnerZone
local inZoneBVel = inZone.BodyVelocity

while true do
local region = Region3.new(pos1, pos2)
wait(1)
inZoneBVel.Velocity = Vector3.new(0,0,0)
--print ("Searching for parts to be in the Zone")
local partsInRegion = workspace:FindPartsInRegion3(region, game.Workspace.Terrain, 100)
local playersFound = {} --Table of players found in Region
for i, part in pairs (partsInRegion) do
if part.Parent:FindFirstChild("Humanoid") ~= nil then
print (part.Parent.Name, "Found in the Zone!")
playersFound[part.Parent.Name] = part.Parent --Add Player's Character to Table
end
end
--Effect of being in the Zone
for plrName, char in pairs (playersFound) do
inZoneBVel.Velocity = Vector3.new(-3,0,0)
end
end

0
You've got an infinite while loop, of course it's going to print that you're within the zone every 1 second and there's nothing you can do about it. If you no longer check the region you wont know whether to move the payload or not. FloweryMonkeyboy5 437 — 5mo
0
better to use a region3 in this case but use whatever u want lol LoganboyInCO 150 — 5mo

0
Edited 5 months ago

Reason your print prints 14 time is that you don't take in account if player is already in region when while true do checks. If you add another of statement to check if player is already in the list of players in region, that will solve your problem:

for i, part in pairs (partsInRegion) do
if part.Parent:FindFirstChild("Humanoid") ~= nil then
if not playersFound[part.Parent.Name] then —part I added
print (part.Parent.Name, "Found in the Zone!")
playersFound[part.Parent.Name] = part.Parent --Add Player's Character to Table
end
end
end

0
Where do I put the "and" Dudez2Good4u 8 — 5mo
0
I said “and” statement, but I wrote not in the code. I meant if you added not like I did at line 3, to check if player is already in list of players in region. I will edit my answer GooierApollo664 163 — 5mo