Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-2

Why does this script not capture a specfic point?

Asked by 10 years ago

I took this script from a control point in the control points template and I modified it to not have the piller thing, as well as have the capture message on the top of the screen instead of a kill log(So like a :h command in Khol's admin house) and now it won't work(So it won't capture the point I have set up). Can I have some help? The script is:




local ControlPoint = script.Parent wait() function WaitForChild(parent, instance) while parent:FindFirstChild(instance) == nil do parent.ChildAdded:wait() end return parent:FindFirstChild(instance) end local RATE = 1/30 local MAX_HEIGHT = 300 local BILLBOARD_STEPS = 50 local TIME_TO_CAPTURE = 15 local POINT_AWARD_RATE = 10 local TeamsService = Game:GetService('Teams') local PlayersService = Game:GetService('Players') local EventFeed = WaitForChild(game.Workspace, 'EventFeed') local AddCustomEvent = WaitForChild(EventFeed, 'AddCustomEvent') local Zone = WaitForChild(ControlPoint, 'Zone') local billboard = WaitForChild(Zone, 'BillboardGui') local ScoreText = WaitForChild(billboard, 'TextLabel') local pad = WaitForChild(ControlPoint, 'Pad') WaitForChild(pad,'Mesh') local PercentControl local ControllingTeamName local ControllingTeamColor local ControllingTeamPlayerCount local TotalPlayerCount local PlayersCapturingByTeam local PlayersCapturingByTeam local ControlPointName = "The Terminal" local radius = (Zone.Size.x + Zone.Size.z) * 0.25 local PercentControl = 1 function RayIgnoreCheck(hit) if hit then if hit.Transparency >= 1 or string.lower(string.gsub(hit.Name,1,6)) == "effect" or hit:IsDescendantOf(ControlPoint) then return true end end return false end function RayCast(startPos, vec, rayLength) local hitObject, hitPos = game.Workspace:FindPartOnRay(Ray.new(startPos + (vec * .01), vec * rayLength), Handle) if hitObject and hitPos then local distance = rayLength - (hitPos - startPos).magnitude if RayIgnoreCheck(hitObject) and distance > 0 then return RayCast(hitPos, vec, distance) end end return hitObject, hitPos end local RayHit, RayEnd = RayCast(pad.Position, Vector3.new(0,1,0), 0) local height = math.min(MAX_HEIGHT, (pad.Position - RayEnd).magnitude) local padlight if ControlPoint:FindFirstChild('Padlight') then padlight = ControlPoint.Padlight else padlight = pad:Clone() end padlight.Name = 'Padlight' padlight.CanCollide = false padlight.Parent = ControlPoint local highlight if ControlPoint:FindFirstChild('Highlight') then highlight = ControlPoint.Highlight else highlight = pad:Clone() end highlight.Name = 'Highlight' highlight.CanCollide = false highlight.Transparency = .75 highlight.Mesh.Offset = Vector3.new(0, height*.5, 0) highlight.Parent = ControlPoint pad.BrickColor = BrickColor.new("Institutional white") billboard.Enabled = false local function ResizeHighlight(PercentControl, height) padlight.Mesh.Scale = pad.Mesh.Scale * Vector3.new(PercentControl, 1, PercentControl) * 1.01 highlight.Mesh.Scale = pad.Mesh.Scale * Vector3.new(PercentControl, height * (1 / highlight.Size.y), PercentControl) end ResizeHighlight(PercentControl, height) Spawn(function() while true do wait(POINT_AWARD_RATE) local AwardTeam = nil for _, CheckTeam in ipairs(TeamsService:GetTeams()) do if CheckTeam.TeamColor == padlight.BrickColor then CheckTeam.Score = CheckTeam.Score + 1 ScoreText.TextColor3 = padlight.BrickColor.Color Spawn(function() ScoreText.TextStrokeTransparency = 0 ScoreText.TextTransparency = 0 billboard.StudsOffset = Vector3.new(0, 5, 0) billboard.Enabled=true for i = 1, BILLBOARD_STEPS do wait(RATE) local percent = i / BILLBOARD_STEPS billboard.StudsOffset = Vector3.new(0, 5 + (percent * 5), 0) ScoreText.TextStrokeTransparency = percent ScoreText.TextTransparency = percent end billboard.Enabled=false end) end end end end) ------------------------------------------------------ local function IsPlayerWithinCaptureRadius(player, capturePosition, captureRadius) if player and player.Character ~= nil then local torso = player.Character:FindFirstChild('Torso') local humanoid = player.Character:FindFirstChild('Humanoid') if torso ~= nil and humanoid~=nil and humanoid.Health > 0 then return torso.Position.y > capturePosition.y and (torso.Position - capturePosition).magnitude < radius end end return false end local function FindTeam(color) for _, team in ipairs(PlayersCapturingByTeam) do if team.color == color then return team end end local team = {color = color, players = {}} table.insert(PlayersCapturingByTeam,team) return team end while true do wait(RATE) PlayersCapturingByTeam = {} for _, player in ipairs(PlayersService:GetPlayers()) do if IsPlayerWithinCaptureRadius(player, Zone.Position, radius + 2) then local team = FindTeam(player.TeamColor) table.insert(team.players, player.Name) end end ControllingTeamColor = BrickColor.new('Medium stone grey') ControllingTeamPlayerCount = 0 TotalPlayerCount = 0 for _, team in ipairs(PlayersCapturingByTeam) do TotalPlayerCount = TotalPlayerCount + #team.players if #team.players > ControllingTeamPlayerCount then ControllingTeamColor = team.color ControllingTeamPlayerCount = #team.players end end if TotalPlayerCount >= 1 then local influence = ControllingTeamPlayerCount - (TotalPlayerCount - ControllingTeamPlayerCount) if influence >= 1 then if padlight.BrickColor == ControllingTeamColor then if PercentControl < 1 then PercentControl = PercentControl + ((RATE / TIME_TO_CAPTURE) * influence) end else PercentControl = PercentControl - ((RATE / TIME_TO_CAPTURE) * influence) end if PercentControl > 1 then PercentControl = 1 elseif PercentControl < 0 then --Take over padlight.BrickColor = ControllingTeamColor highlight.BrickColor = ControllingTeamColor PercentControl = 0 ControllingTeamName = "" for _, team in ipairs(TeamsService:GetTeams()) do if team.TeamColor == ControllingTeamColor then ControllingTeamName = team.Name .. "#" end end if ControllingTeamName ~= "" then AddCustomEvent:Invoke(ControllingTeamName,'['..tostring(ControllingTeamColor.Number)..']'," captured "..ControlPointName.."!") else AddCustomEvent:Invoke(ControlPointName.." has been captured!") end end ResizeHighlight(PercentControl, height) end end end
0
This code is too long. Please only post the code that is relevant to your issue. bbissell 346 — 10y
0
I don't know what part of the code I'm having problems with. Theepicpaintballer5 0 — 10y

Answer this question