Hello!
I’m working on some fun collection service stuff to automatically convert parts to certain models depending on a tag they have to make placement easier, but sometimes when playtesting, the code just goes past the i, v loop.
Here’s a look at what’s happening when the script fails:
![]()

Here’s what’s supposed to happen:
![]()

When the script “fails”, there aren’t any errors output in the console, so I’m really unable to pinpoint where the script is going wrong, whether it be a problem with the script or just a Roblox thing.
Here’s my code, local script in StarterGui:
local collectionService = game:GetService('CollectionService')
local replicatedStorage = game:GetService('ReplicatedStorage')
local springIncrement = 2
print('running: '.. script:GetFullName())
for i, object in pairs(collectionService:GetTagged('spring')) do
print('sproing!')
local newSpring = replicatedStorage.spring:Clone()
newSpring:SetPrimaryPartCFrame(object.CFrame)
newSpring.Parent = workspace
object:Destroy()
local bumper = newSpring:WaitForChild('bumper')
local spring = newSpring:WaitForChild('spring')
newSpring.Positioner:Destroy()
bumper.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) and not newSpring:HasTag('springActive') then
collectionService:AddTag(newSpring, 'springActive')
local origBumperPos = bumper.Position
local origSpringPos = spring.Position
local origSpringSize = spring.Size
bumper.Position += Vector3.new(0,springIncrement,0)
spring.Size += Vector3.new(0,0,springIncrement)
spring.Position += Vector3.new(0,springIncrement/2,0)
bumper.Material = Enum.Material.Neon
spring.Material = Enum.Material.Neon
local hrp = hit.Parent.HumanoidRootPart :: Part
local sound = script.spring
sound.PlaybackSpeed = Random.new():NextNumber(0.9, 1.3)
sound:Play()
-- EFFECT --
local bodyVel = Instance.new('BodyVelocity')
bodyVel.Velocity = Vector3.new(0,100,0)
bodyVel.MaxForce = Vector3.new(100000,100000,100000)
bodyVel.P = math.huge
bodyVel.Parent = hrp
game:GetService('Debris'):AddItem(bodyVel, 0.1)
task.delay(0.2, function()
bumper.Position = origBumperPos
spring.Size = origSpringSize
spring.Position = origSpringPos
end)
task.delay(0.4, function()
spring.Material = Enum.Material.Plastic
bumper.Material = Enum.Material.Plastic
collectionService:RemoveTag(newSpring, 'springActive')
end)
end
end)
end
print('finished!')
Any help would be appreciated! As much as the script works most of the time, I would rather it works all of the time.