Capture Point Team specific points

Im try to get this to basically stop giving Dragoons if the player is no longer on that team or never on that team to begin with

CapturePart.Touched:Connect(function(Part)
	if Players:GetPlayerFromCharacter(Part.Parent) then
		local Player = Players:GetPlayerFromCharacter(Part.Parent)
		if Player.Team ~= nil and tostring(Player.Team) ~= CaptureText.Text then
			wait(2)
			CaptureText.Text = tostring(Player.Team)
			if CaptureSound.Playing == false then
				CaptureSound:Play()
			if Player.Team.Name == CaptureText.Text then
				while true do
				Player.Data_Folder.Dragoons.Value += 500 
					wait(120)
			if not Player.Team.Name == CaptureText.Text then
				Player.Data_Folder.Dragoons.Value = Player.Data_Folder.Dragoons.Value	
					end
				end
			end
			for i,v in pairs(Players:GetPlayers()) do
				pcall(function()
					ShowCaptureUI(v, tostring(v.Team), "Private Docks of Kings Landing") --Place name--
					task.wait(CaptureSoundLength)
					HideCaptureUI(v)
				end)
			end
		end
	end
end)

any thoughts on how to adjust it?

I would also like it to automatically recheck if the captured team has changed and if so to stop giving dragoons to the original team and change to new team.