local topbeam=script.Parent.Parent.Beams.High
local beams=script.Parent.Parent.Beams:GetChildren()
local capturetime=5
local m=Instance.new("Message")
local giving=false
function givepoints()
giving=true
while wait(1) do
if script.Parent.Parent.HoldingTeam.Value==Game.Teams["Storm Brigade"] then
Workspace.SBPoints.Value=Workspace.SBPoints.Value+1
elseif script.Parent.Parent.HoldingTeam.Value==Game.Teams.Raiders then
Workspace.RaiderPoints.Value=Workspace.RaiderPoints.Value+1
end
end
end
local lowerbeam = coroutine.wrap(function()
for i=topbeam.Size.X, 13, -1 do
for x, y in pairs(beams) do
y:Resize(Enum.NormalId.Right, -1)
wait()
end
end
end)
script.Parent.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local player=Game.Players:FindFirstChild(hit.Parent.Name)
if player then
for i, v in pairs(beams) do
v.BrickColor=player.TeamColor
end
for i, v in pairs(Game.Teams:GetChildren()) do
if v.TeamColor==player.TeamColor then
script.Parent.Parent.HoldingTeam.Value=v
end
end
local beamheight=topbeam.Position.Y+(topbeam.Size.Y/2)
local floaterheight=script.Parent.Parent.FortFloaters.FortFloaters.Position.Y-(script.Parent.Parent.FortFloaters.FortFloaters.Size.Y/2)-100
for i=beamheight, floaterheight do --transition to the new fort color
for x, y in pairs(beams) do
y.Size=y.Size+Vector3.new(1, 0, 0)
y.Position=y.Position+Vector3.new(0, 0.5, 0)
end
wait(capturetime/(floaterheight-beamheight))
end
for i, v in pairs(script.Parent.Parent.FortFloaters:GetChildren()) do
if v:IsA("BasePart") then
v.BrickColor=player.TeamColor
end
end
m.Parent=Workspace
m.Text="The Fort has been captured by the "..script.Parent.Parent.HoldingTeam.Value.Name..[[!
Their soldier ]]..player.Name..[[ has breached the defenses and activated the capture point to take the fort!]]
lowerbeam()
wait(3)
m:Remove()
if not giving then
givepoints()
end
end
end
end)
Everything goes seamlessly the first time the touched is called. The second time though, I run into the same issue I did before: the touched function cuts off at line 57, but this time I get an error:
`16:22:14.631 - Workspace.CapturePoint.Trigger.Script:57: cannot resume dead coroutine
16:22:14.631 - Script 'Workspace.CapturePoint.Trigger.Script', Line 57
16:22:14.631 - Stack End`

6 comments
lowerbeam affects three parts, each with a cylinder mesh in them. I'll go try that...
I tried it, and now I get an error the second time the script is run, but the first time it works seamlessly. I got an error this time too, see the edited question.
check i think that'll work
ok, I'll go try this in a bit...
Will other things still run while the function is running?
thanks, it works perfectly, and other things run while it's running (which is just what I wanted it to do)!