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`
I'm not sure what objects the lowerbeam is affecting but you can try making that a coroutine
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)
You dont need to change line 56 btw. Keep it as lowerbeam()
Keep in mind that the other stuff will run WHILE that function is running so you can add a variable called BeamLowered = false
and when its done you can set it to true while the line AFTER lowerbeam()
waits for that and it would look like this
while not BeamLowered do wait() end
RE-EDIT I think if you wrap it in a function it will create instead of resume
function lowerbeam() local lowerTEHbeam = 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) lowerTEHbeam() end