You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve?
Basic capture point system in fps games. -
What is the issue?
They are not recapturable.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local uncapturedPoints = {}
local prefix = ":"
local gameStarted = false
local interval = 1
local increment = 50
local capturePointsFolder = ReplicatedStorage.CapturePoints
local capturePoints = capturePointsFolder.Points
local remotes = ReplicatedStorage.Remotes
local remoteEvent = remotes.RemoteEvent
Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(message)
if message == prefix .. "start" then
if gameStarted then
return
end
gameStarted = true
local clonedPoints = capturePoints:Clone()
clonedPoints.Parent = workspace
for _, point in ipairs(clonedPoints:GetChildren()) do
local loop = coroutine.wrap(function()
while true do
local teamOne = point:FindFirstChild("The Soviet Military")
local teamTwo = point:FindFirstChild("Raiders")
local gui = point:FindFirstChild("Gui")
local pointName = gui:FindFirstChild("PointName")
local touchingParts = workspace:GetPartsInPart(point)
for _, v in ipairs(touchingParts) do
if v.Name == "HumanoidRootPart" then
local character = v.Parent
local player = Players:GetPlayerFromCharacter(character)
local team = player.Team
print("1")
if team.Name == teamOne.Name then
print("2")
if teamOne.Value == 100 then
print("3")
return
end
if teamTwo.Value > 0 then -- If raiders have points
print("4")
teamTwo.Value -= increment
local backgroundColor = pointName.BackgroundColor3
pointName.BackgroundColor3 = Color3.new(backgroundColor.R, backgroundColor.G - .1, backgroundColor.B)
else -- If raiders do not have points
teamOne.Value += increment
local backgroundColor = pointName.BackgroundColor3
pointName.BackgroundColor3 = Color3.new(backgroundColor.R + .1, backgroundColor.G, backgroundColor.B)
end
else
print("5")
if teamTwo.Value == 100 then
return
end
if teamOne.Value > 0 then -- If soviets have points
teamOne.Value -= increment
local backgroundColor = pointName.BackgroundColor3
pointName.BackgroundColor3 = Color3.new(backgroundColor.R - .1, backgroundColor.G, backgroundColor.B)
else --If soviets do not have points
teamTwo.Value += increment
local backgroundColor = pointName.BackgroundColor3
pointName.BackgroundColor3 = Color3.new(backgroundColor.R, backgroundColor.G + .1, backgroundColor.B)
end
end
if teamOne.Value == 100 then
remoteEvent:FireAllClients({
purpose = "textDisplay",
text = teamOne.Name .. " have captured " .. point.Name,
duration = 5
})
elseif teamTwo.Value == 100 then
remoteEvent:FireAllClients({
purpose = "textDisplay",
text = teamTwo.Name .. " have captured " .. point.Name,
duration = 5
})
end
end
end
local teamOnePoints = {}
local teamTwoPoints = {}
for _, v in ipairs(clonedPoints:GetChildren()) do
if v[teamOne.Name].Value == 100 then
table.insert(teamOnePoints, v)
elseif v[teamTwo.Name].Value == 100 then
table.insert(teamTwoPoints, v)
end
end
if #teamOnePoints == #clonedPoints:GetChildren() then
gameStarted = false
clonedPoints:Destroy()
remoteEvent:FireAllClients({
purpose = "textDisplay",
text = teamOne.Name .. " H A S W O N !",
duration = 5
})
break
elseif #teamTwoPoints == #clonedPoints:GetChildren() then
gameStarted = false
clonedPoints:Destroy()
remoteEvent:FireAllClients({
purpose = "textDisplay",
text = teamOne.Name .. " H A S W O N !",
duration = 5
})
break
end
task.wait(interval)
end
end)()
end
end
end)
end)