My objective is to make a variable (_G.rownedB and _G.gownedB) that adds points to _G.RPoints or _G.GPoints 1 per 1 second until either one of them has 1200 points. Unfortunately, it does not seem to be functioning correctly and is instead failing to work at all, launching the game and seeing that when I capture the point, the point gui text (_G.News.Text) does not work. What is my mistake?
-- Script by Dropdatderp
capturing = nil
_G.rownedB = false
_G.gownedB = false
neutral = true
function get_player(part)
for _, player in ipairs(game.Players:GetPlayers()) do
if part:IsDescendantOf(player.Character) then
return player
end
end
end
function onTouched(part)
local h = part.Parent:findFirstChild("Humanoid")
if h ~= nil then
if _G.gownedB or neutral == true then
capturing = true
_G.News.Text = "Raiders are taking Point B!"
wait(10)
_G.News.Text = "Raiders have taken Point B."
capturing = nil
_G.rownedB = true
_G.gownedB = false
neutral = false
end
elseif _G.rownedB or neutral == true then
local player = get_player(part)
if player:IsInGroup("901313") then
capturing = true
_G.News.Text = "Defenders are taking Point B!"
wait(10)
_G.News.Text = "Defenders have taken Point B."
capturing = nil
_G.rownedB = false
_G.gownedB = true
neutral = false
repeat
wait(1)
_G.RPoints = _G.RPoints + 1
until _G.RPoints or _G.GPoints == 1200
end
end
end
repeat
script.Parent.Touched:connect(get_player)
script.Parent.Touched:connect(onTouched)
until _G.GPoints == 1200 or _G.RPoints == 1200