Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local teamtaking = script.Parent:WaitForChild("teamtaking")
- local team = script.Parent:WaitForChild("team")
- local flag = script.Parent:WaitForChild("flag")
- local poleTag = script.Parent:WaitForChild("pole").BillboardGui.tag -- you could also wait for BillboardGui and tag here if you wanted
- local number = 0
- local max = 13
- function setNumber(newNumber)
- number = newNumber
- local absNumber = math.abs(newNumber)
- if absNumber > max then return end
- flag.CFrame = CFrame.new(126.961, 377.416 + absNumber, -419.518)
- end
- function recordTeamIsCapturing(teamName, flagColor, poleColor, captureDir, modelName)
- -- returns true if the team successfully captured the flag
- -- teamName: "R", "B", etc
- -- captureDir: what to change 'number' by (-1 or 1)
- -- modelName: the name of the model in script.Parent to reward players by (ex "rplayers" or "bplayers")
- if number == 0 then
- flag.BrickColor = flagColor
- poleTag.BackgroundColor3 = poleColor
- end
- setNumber(number + captureDir)
- local plr
- for _, player in ipairs(script.Parent[modelName]:GetChildren()) do
- local plr = game.Players:GetPlayerFromCharacter(player.Value)
- if plr then
- plr.playerpointstore.Value = plr.playerpointstore.Value + 10
- end
- end
- if number == max * captureDir then
- team.Value = teamName
- return true
- else
- return false
- end
- end
- local db = false
- function flag()
- if db then return end
- db = true
- local captured
- while true do
- if teamtaking.Value == "R" and number ~= max then
- captured = recordTeamIsCapturing("R", BrickColor.new("Bright red"), Color3.new(1,0.137254902,0.137254902), 1, "rplayers")
- if captured then break end
- elseif teamtaking.Value == "B" and number ~= -max then
- captured = recordTeamIsCapturing("B", BrickColor.new("Bright blue"), Color3.new(0.137254902,0.137254902,1), -1, "bplayers")
- if captured then break end
- elseif teamtaking.Value == "N" then
- if team.Value == "R" and number ~= max then
- setNumber(number + 1)
- if number == max then break end
- elseif team.Value == "B" and number ~= -max then
- team.Value = "B"
- if number == -max then break end
- elseif team.Value == "N" then
- if number < 0 then
- setNumber(number + 1)
- elseif number > 0 then
- setNumber(number - 1)
- end
- if number == 0 then
- flag.BrickColor = BrickColor.new("Institutional white")
- poleTag.BackgroundColor3 = Color3.new(1,1,1)
- break
- end
- end
- end
- wait(1)
- end
- db = false
- end
- teamtaking.Changed:connect(function()
- flag()
- end)
Advertisement
Add Comment
Please, Sign In to add comment